Local Runtimesollamadocker

How to configure Ollama for remote access, and why you need a reverse proxy in front of it

Error
curl: (28) Failed to connect to 192.168.1.50 port 11434: Connection timed out

Also appears as

  • OLLAMA_HOST=0.0.0.0 still refuses remote connections
  • Connection refused when accessing Ollama from another machine on the network

Short answer

Ollama binds to 127.0.0.1 by default, which blocks any connection from another machine, container, or network. Setting OLLAMA_HOST=0.0.0.0 makes it listen on all interfaces, but Ollama's API has no built-in authentication, so any remote-accessible instance must sit behind a reverse proxy or VPN that adds authentication and TLS before it is exposed beyond a fully trusted local network.

Affects: Any Ollama install where clients connect from a different machine, container, or network than the one running the service

Fastest path to safe remote access

  1. 1Set the environment variable OLLAMA_HOST=0.0.0.0:11434 on the machine running Ollama and restart the service.
  2. 2Confirm it is listening on all interfaces: ss -tlnp | grep 11434 should show 0.0.0.0:11434, not 127.0.0.1:11434.
  3. 3Open port 11434 in the firewall only for the specific source IPs or subnet you trust, never for the whole internet.
  4. 4Put a reverse proxy (nginx, Caddy, or Traefik) in front of Ollama that terminates TLS and enforces basic auth or an API key.
  5. 5Point remote clients at the reverse proxy's address and port, not directly at 11434.

How to confirm this is your problem

  • curl or an HTTP client from another machine times out or is refused, while it works fine on the Ollama host itself
  • ss or netstat shows Ollama bound to 127.0.0.1:11434 instead of 0.0.0.0:11434
  • A Docker container on the same host cannot reach Ollama running on the host without extra networking configuration
  • After setting OLLAMA_HOST, remote access still fails because a firewall rule was never updated

Root causes and fixes

Most common

OLLAMA_HOST was never set, so Ollama binds to localhost only

Ollama's default bind address is 127.0.0.1, a deliberate safety default because the API has no authentication; without explicitly setting OLLAMA_HOST to 0.0.0.0 or a specific reachable interface IP, the socket only accepts connections originating from the same machine, so any remote client is refused at the TCP level regardless of firewall state.

Fix: Set OLLAMA_HOST=0.0.0.0:11434 as an environment variable for the ollama service and restart it, then verify the bind address with ss -tlnp.

Commands
export OLLAMA_HOST=0.0.0.0:11434
systemctl restart ollama
ss -tlnp | grep 11434
Common

Firewall still blocking the port after rebinding

Rebinding to 0.0.0.0 only changes what the process listens on; it does nothing to open the host firewall or a cloud security group, so a remote request can still be dropped before it ever reaches the Ollama process even though the bind address is now correct.

Fix: Explicitly allow inbound TCP on port 11434 from your trusted subnet in ufw, firewalld, or your cloud provider's security group, and re-test from the remote machine.

Commands
sudo ufw allow from 10.0.0.0/8 to any port 11434
Common

Exposing Ollama directly to an untrusted network without a proxy

Ollama's API accepts any request that reaches it, with no login, token, or API key by default; opening it directly to a broad network, a public IP, or the open internet means anyone who finds the port can run inference or pull model listings, which is a real data exposure and cost risk, not a theoretical one.

Fix: Never expose port 11434 directly beyond a fully trusted network. Put nginx, Caddy, or a similar reverse proxy in front that adds TLS and an authentication layer (API key header, basic auth, or OAuth) before forwarding to Ollama.

Commands
# nginx: proxy_pass http://127.0.0.1:11434, with an auth_request or API key check in front
Occasional

Docker container networking isolating Ollama from the host or other containers

A containerized Ollama with default bridge networking is reachable at a container-internal address, not localhost, from other containers or the host; clients using localhost or 127.0.0.1 from outside that container's namespace will fail even though OLLAMA_HOST is correctly set to 0.0.0.0 inside the container.

Fix: Publish the port explicitly with -p 11434:11434, or use host networking, and have clients connect to the host's actual IP or hostname rather than localhost.

Commands
docker run -d -p 11434:11434 -e OLLAMA_HOST=0.0.0.0:11434 ollama/ollama
Rare

Client using the wrong hostname or an outdated DNS/IP entry

If the Ollama host's IP address changed (common with DHCP or cloud instances being recreated) but the client configuration or a cached DNS entry still points at the old address, connections will time out even though the server itself is correctly configured for remote access.

Fix: Confirm the current IP or hostname of the Ollama host and update client configuration, or assign a static IP or DNS name to avoid this recurring.

Commands
hostname -I

Diagnostic commands

Check the actual bind address

ss -tlnp | grep 11434

0.0.0.0:11434 means it is listening on all interfaces; 127.0.0.1:11434 means only local connections work regardless of firewall state.

Test connectivity from the remote client

curl -v http://<ollama-host-ip>:11434/api/tags

Connection refused means the port is reachable but nothing is listening correctly there; connection timed out usually means a firewall or security group is dropping the packets silently.

Verify the environment variable took effect

systemctl show ollama -p Environment

Confirms whether OLLAMA_HOST is actually set in the running service's environment, since a typo or a config file that was not reloaded is a common reason the setting appears ignored.

Stopping it from happening again

  • Never bind Ollama's API to 0.0.0.0 without also placing an authenticating reverse proxy in front of it.
  • Scope firewall rules to specific trusted subnets rather than opening the port broadly, and review them on a schedule.
  • Use a static IP, internal DNS name, or service discovery entry for the Ollama host so client configuration does not silently rot.
  • If remote access is only needed occasionally, prefer an SSH tunnel or VPN over a permanently open port.

When this becomes an architecture problem

The moment more than one team or an external partner needs access to your Ollama instance, or you need audit logs of who queried what, you have outgrown a single bound-and-firewalled Ollama box and need a proper API gateway with authentication, rate limiting, and logging in front of your inference layer.

Frequently asked questions

Is it safe to set OLLAMA_HOST=0.0.0.0 on a cloud VM with a public IP?

Not by itself. That setting only controls which network interfaces Ollama listens on; it adds no authentication. Combine it with a firewall or security group that blocks the port from the public internet and a reverse proxy that requires authentication for any traffic you do allow through.

Does Ollama support API keys or authentication natively?

Ollama's core API does not include built-in authentication as of current releases. Any access control has to be added externally, typically through a reverse proxy that checks an API key or token before forwarding requests to Ollama.

Can I access Ollama remotely without opening any firewall port?

Yes, an SSH tunnel forwards the port over an already-authenticated SSH connection without exposing 11434 to the network at all, which is a good option for occasional remote access.

Related problems

Ollama connection refused when calling the API

Ollama connection refused almost always means the ollama serve process is not running, is listening on a different interface than expected, or is bound to 127.0.0.1 while your client is calling it from another host or container. Start or restart the service, confirm it is listening on 11434, and if you need remote access set OLLAMA_HOST to 0.0.0.0 explicitly.

Ollama says a model was not found

Ollama model not found means the exact tag you requested, including the version suffix after the colon, does not exist locally or in the registry. Either the tag has a typo, the model was never pulled, or a custom Modelfile references a FROM path that does not resolve on this machine. Run ollama list to see what is actually installed, then pull or fix the Modelfile.

GPU not visible inside a Docker container

Docker containers cannot see a host GPU unless the NVIDIA Container Toolkit is installed and the nvidia runtime is registered with the daemon, since containers are isolated from host devices by default. The fix is almost always to install nvidia-container-toolkit, run nvidia-ctk runtime configure, restart Docker, and launch with --gpus all. If nvidia-smi already fails on the host itself, the problem is the driver, not Docker.

Kubernetes readiness probe fails while the model is still loading

LLM service pods get killed or marked unready during startup because default Kubernetes readiness and liveness probes assume a service starts in seconds, while loading multi-gigabyte weights into GPU memory can take minutes. Add a startupProbe sized with a failureThreshold times periodSeconds budget that comfortably exceeds your worst-case load time; Kubernetes suppresses readiness and liveness checks entirely until the startup probe succeeds, which stops premature restarts without needing a fragile fixed initialDelaySeconds guess.

Guide

On-Prem LLM Deployment Architecture: Reference Guide

Reference architecture for on-prem LLM deployment: inference servers, GPU sizing, RAG pipelines, and security zones for regulated manufacturers.

Guide

Securing Model Weights in the Enterprise

Secure model weights end to end: custody controls, encryption at rest, access policies, and exfiltration prevention for regulated AI deployments.

Still stuck, or tired of fighting your own infrastructure?

Netray deploys and operates on-prem AI for regulated manufacturers and defense suppliers. We have debugged this stack in production, on air-gapped networks, at scale.