All articles
Ollama & llama.cppFixes

OLLAMA_HOST=0.0.0.0: How to Set It on Mac, Linux, Windows and Docker (Tested on v0.40.15)

Ollama listens on 127.0.0.1:11434 unless you set OLLAMA_HOST. We started v0.40.15 with several values, checked what it listened on and who could connect, and tested OLLAMA_ORIGINS. Mac, Linux, Windows and Docker steps follow the official FAQ.

Ollama OLLAMA_HOST=0.0.0.0: beige clay llama server box wrapped in a mint network cable with two clay laptops, soft light
Also available in中文Español

Short answer: with no settings, Ollama listens only on 127.0.0.1:11434, so only the local machine can connect (the official FAQ says it binds 127.0.0.1 port 11434 by default). To let other devices on your network connect, change the bind address with the OLLAMA_HOST environment variable; the usual value is 0.0.0.0:11434. The variable has to reach the server process: an export in your current terminal is not seen by the background Ollama app or the systemd service. On November 10, 2026 we ran Ollama v0.40.15 on Linux with several values and recorded what happened.

Tested: where each value listens

Setup: Linux (container), Ollama v0.40.15, several servers on different ports at the same time, no model pulled. “The machine’s LAN IP” means this machine’s own address on the network, queried with curl on /api/version.

OLLAMA_HOST valueListening line in the logVia 127.0.0.1Via the machine’s LAN IP
127.0.0.1:11601Listening on 127.0.0.1:11601Works, returns {"version":"0.40.15"}Does not connect, no response
0.0.0.0:11602Listening on [::]:11602WorksWorks, returns {"version":"0.40.15"}
0.0.0.0 (no port)Listening on [::]:11434Not tested separatelyNot tested separately
:11603 (port only)Listening on [::]:11603Not tested separatelyNot tested separately

How to read it:

  • With 0.0.0.0, v0.40.15 logs [::] and ss -ltn shows *:11602, meaning all interfaces. We did not test IPv6 access separately.
  • With no port, the port falls back to 11434. A port only (:11603) also listens on all interfaces.
  • “Works” only means the network path is open. curl got a response with no credentials at all, so once it listens on all interfaces, anyone on that network can call it. The security section below covers this.

The client reads the same variable. From another machine, pointing OLLAMA_HOST at the server’s IP and port and running ollama list connected and returned the header row (NAME ID SIZE MODIFIED; empty because no model was pulled). With no server running, plain ollama list fails with:

Error: could not connect to ollama server, run 'ollama serve' to start it

How to set it per platform (on the service)

These steps come from the official FAQ. We only ran ollama serve directly on Linux; the macOS, Windows, systemd and Docker steps were not run on those systems and follow the docs.

macOS (Ollama app)

launchctl setenv OLLAMA_HOST "0.0.0.0:11434"

Then quit and reopen the Ollama app.

Linux (systemd service)

sudo systemctl edit ollama.service

In the editor, add:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Save, then:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Windows

Quit Ollama from the tray, open “Edit environment variables for your account”, create or edit the user variable OLLAMA_HOST with the value 0.0.0.0:11434, click OK, and start Ollama again from the Start menu.

Docker

The official image’s Dockerfile already has ENV OLLAMA_HOST=0.0.0.0:11434 (we read the Dockerfile on GitHub; we did not run the container), so inside the container it already listens on all interfaces. What you control is the port mapping: -p 11434:11434 publishes on all host interfaces; use -p 127.0.0.1:11434:11434 to keep it local. For another container to reach Ollama on the host, Docker Desktop offers host.docker.internal; on Linux you usually add --add-host=host.docker.internal:host-gateway. The port-mapping syntax and these two points are general Docker practice, not Ollama documentation, and we did not test them.

How to confirm it worked

1. On the server, check the listener: on Linux ss -ltn | grep 11434. *:11434 or 0.0.0.0:11434 means it listens externally; 127.0.0.1:11434 means local only.

2. From another machine:

curl http://SERVER_IP:11434/api/version

A JSON reply like {"version":"0.40.15"} means it works; that is the format we got.

3. If it fails, check that the firewall allows 11434 (macOS, Windows and Linux firewalls can block it; we did not test this), then check that the client is not still pointing at the default address.

Browser pages and extensions: OLLAMA_ORIGINS

OLLAMA_HOST decides who can connect; web pages and extensions in a browser also face a cross-origin check, which OLLAMA_ORIGINS controls. The FAQ says cross-origin requests from 127.0.0.1 and 0.0.0.0 are allowed by default and anything else must be added with OLLAMA_ORIGINS. We tested with a CORS preflight (OPTIONS) on v0.40.15:

SettingOriginPreflight result
OLLAMA_ORIGINS unsethttp://localhost:3000204 with Access-Control-Allow-* headers
OLLAMA_ORIGINS unsethttp://evil.example403 Forbidden
OLLAMA_ORIGINS=http://app.example.comhttp://app.example.com204
OLLAMA_ORIGINS=http://app.example.comhttp://other.example.com403

So if a web front end gets a CORS error from Ollama, change OLLAMA_ORIGINS, not OLLAMA_HOST. For browser extensions the FAQ shows chrome-extension://*,moz-extension://*,safari-web-extension://*; allowing only the one you use is safer.

Security: 0.0.0.0 means open to the whole network

  • In our test, calls worked with no credentials, so never publish port 11434 to the internet (router port forwarding or a wide-open cloud security group both count).
  • Use it only on a trusted LAN. Cafés, dorms and shared office networks are not trusted.
  • If you really need remote access, the FAQ’s approach is a reverse proxy in front (the example is Nginx; it also shows Cloudflare Tunnel), with the proxy doing access control while Ollama keeps listening locally.
  • If you only need other local programs (for example an app in a Docker container) to reach it, prefer listening on 127.0.0.1 or restrict the source with the port mapping above.

FAQ

I set OLLAMA_HOST but the local 127.0.0.1 still fails?

The client reads the variable too. Setting the server to 0.0.0.0:11434 is fine, but if your terminal has OLLAMA_HOST set to something else, ollama list and ollama run connect to that address. Run echo $OLLAMA_HOST to see what the current terminal has.

The setting does not take effect

Usually the variable never reached the server process: on macOS use launchctl setenv and restart the app, on Linux put it in the systemd Environment= and run daemon-reload and restart, on Windows quit the tray app and start it again. The same applies to proxy variables; see the max retries exceeded proxy fix.

Related

Ollama and llama.cpp error list · Ollama context length · Best local LLMs

Leave a thought

Your email address will not be published.