Expose the Ollama API Safely on Your Network

Expose the Ollama API Safely on Your Network

Kimi Lu

Cover image for How to Run Ollama and Connect to the Service API Through Internal Network or Internet

Expose the Ollama API Safely on Your Network

To make Ollama reachable from another device on your local network, set OLLAMA_HOST to 0.0.0.0:11434, restart Ollama, and allow port 11434 only from the network that should use it. Do not expose the raw Ollama port directly to the public internet. For remote access, put it behind a VPN or an authenticated HTTPS reverse proxy.

Quick Answer

Goal

Recommended setup

Use Ollama on the same computer

Keep the default 127.0.0.1:11434 binding

Use Ollama from trusted devices on one LAN

Bind to 0.0.0.0:11434 and restrict the firewall to the LAN subnet

Use Ollama while away from home or the office

Use a private VPN or an HTTPS reverse proxy with authentication

Share a centrally operated service with a team

Treat Ollama as a remote service with identity, access, logging, and capacity controls

This is the same trust-boundary decision that applies when choosing between local and remote MCP servers: decide who operates the service, who can reach it, and where credentials and data cross a network boundary.

Before You Change the Bind Address

Ollama listens on 127.0.0.1:11434 by default. Changing the address to 0.0.0.0:11434 makes it listen on every network interface, but your operating-system firewall and network router still determine which clients can connect.

Before continuing:

  1. Identify the server's private IP address, such as 192.168.1.105.

  2. Decide which subnet or specific devices should have access.

  3. Keep the server and downloaded models patched.

  4. Use a VPN or authenticated reverse proxy for any access beyond a trusted LAN.

Configure Ollama on macOS

When Ollama runs as the macOS application, set its environment variable with launchctl:

Quit Ollama completely, then open it again. To return to local-only access later:

Restart Ollama after changing the value.

Configure Ollama on Linux

When Ollama runs as a systemd service, create a service override:

Add only this override above the editor's discard marker:

Then reload the service configuration and restart Ollama:

Confirm that the server is listening:

Configure Ollama on Windows

Ollama inherits Windows user and system environment variables:

  1. Quit Ollama from the taskbar.

  2. Open Edit environment variables for your account.

  3. Create or update OLLAMA_HOST with the value 0.0.0.0:11434.

  4. Save the change and start Ollama again.

If another device still cannot connect, check Windows Defender Firewall and confirm that the inbound rule is limited to the intended private network profile.

Test the Connection

First test from the Ollama server itself:

Then test from another device, replacing the address with the server's private IP:

Finally, test a generation request with a model you already installed:

The Ollama API documentation lists the current endpoints and request formats.

Restrict Firewall Access

Avoid opening port 11434 to every source. On a Linux server using UFW, allow only your trusted LAN subnet:

Use your actual subnet. A narrower rule for one client IP is better when only one machine needs access.

Use a Safer Pattern for Internet Access

Direct router port forwarding sends public traffic straight to Ollama. A safer design is one of these:

  • Private VPN: connect the client and server through Tailscale, WireGuard, or another private network and keep Ollama unavailable to the public internet.

  • Authenticated reverse proxy: terminate HTTPS at Nginx, Caddy, Cloudflare Access, or another gateway that enforces identity before forwarding to 127.0.0.1:11434.

  • Application backend: keep Ollama private and expose only the narrow operations your application needs, with authentication, input limits, timeouts, and rate limits.

If several people or agents share the service, also plan for model memory, concurrent requests, logs, and abuse limits. Network reachability is only one part of operating a reliable remote inference service.

Browser Clients and CORS

For a browser-based client on another origin, configure OLLAMA_ORIGINS with the exact trusted origin rather than a wildcard. The official Ollama FAQ documents this environment variable and proxy examples. CORS controls which browser origins may call the API; it does not replace authentication or firewall rules.

Troubleshooting

Connection refused

  • Confirm Ollama is running.

  • Confirm OLLAMA_HOST includes :11434.

  • Check the listening socket with ss, netstat, or PowerShell.

  • Test locally before testing from another device.

  • Verify that the firewall rule matches the correct private subnet.

The local request works but the LAN request times out

The service is usually still bound to loopback, the host firewall is blocking the request, or the two devices cannot route to each other. Guest Wi-Fi and client-isolation settings commonly block device-to-device traffic.

A browser reports a CORS error

Add the exact web application's origin to OLLAMA_ORIGINS, restart Ollama, and confirm that the proxy preserves the expected Host header. Do not solve a CORS error by making the server publicly reachable.

The API returns 404

Test a documented endpoint such as /api/tags. A response from the server means the network path works; a 404 usually means the requested path is wrong rather than the port being unreachable.

Conclusion

For trusted local devices, bind Ollama to 0.0.0.0:11434, restrict the firewall, and test from both the host and a client. For remote users, keep the raw port private and add a VPN or authenticated HTTPS boundary. That gives you network access without turning a local model server into an unprotected public endpoint.

If you are connecting agents to shared SaaS and production tools rather than a local model server, Aident Loadout provides managed authentication, discovery, and audit for agent tool access.

Sources

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.