Ollama connection refused on 127.0.0.1:11434 — every fix
Refused on 127.0.0.1:11434 means nothing is listening — the kernel sent RST before Ollama saw the request. Check ss -tln | grep 11434, run systemctl enable --now ollama, check OLLAMA_HOST.
Ollama connection refused on 127.0.0.1:11434 means nothing is listening — the kernel sent RST before Ollama ever saw the request. A firewall that drops gives you a timeout; a refusal convicts the endpoint and clears the network path.
systemctl enable --now ollama on Linux, or ollama serve in any terminal. If ss -tln | grep 11434 is empty, nobody is listening; if it shows a listener on another address, OLLAMA_HOST moved the bind.A refused connection is a placement problem, not a broken program: something that should be listening isn't, or the caller is calling from a place the listener doesn't reach.
Ollama's default port since its first release. Refused means no socket was bound there — Ollama never saw the packet.
Why is 127.0.0.1:11434 refusing connections?
- Confirm the failure.
curl http://127.0.0.1:11434— see the exact error once so the fix is provable. - Check the port.
ss -tln | grep 11434. A line likeLISTEN 0 128 127.0.0.1:11434means somebody is home; empty means nobody. - Start the server.
sudo systemctl enable --now ollamaorollama serve. Success is exactly one line:Ollama is running. Theenableis what survives a reboot;startbuys one boot. - Check OLLAMA_HOST. Read once when the server starts, default
127.0.0.1:11434. Set it in the unit's override, not your shell:sudo systemctl edit ollama, thenEnvironment="OLLAMA_HOST=0.0.0.0:11434"and restart. - Check who's asking. Container loopback is the container, not the host: use
--add-host=host.docker.internal:host-gatewayand callhttp://host.docker.internal:11434.
| Where you see it | Likely cause | Fix |
|---|---|---|
refused, ss shows nothing | server never started (or died at boot) | systemctl enable --now ollama / ollama serve |
| starts, then refuses minutes later | crash loop — port taken, disk full, bad env | journalctl -u ollama -n 50, fix what it names |
| server answers on 11435, clients call 11434 | custom OLLAMA_HOST moved the port | point clients at the real port |
127.0.0.1 works, localhost refuses | localhost resolves to IPv6 ::1 first | call 127.0.0.1, or bind both |
| host fine, container refused | container loopback ≠ host loopback | host.docker.internal + host-gateway |
| container-to-container refused | used localhost instead of the service name | http://<service-name>:11434 |
| other machine on LAN refused | loopback-only bind (default); the API has no auth | OLLAMA_HOST=0.0.0.0:11434 in the override |
| refused after reboot every time | start without enable | systemctl enable ollama |
| works for days, refused without warning | a hand-started second instance stole the port | ss -ltnp, kill the stray, keep the service |
| hangs, then times out | firewall dropping, not refusing | different problem — allowlist the port |
Why does it work in the terminal but not from Docker or n8n?
Because 127.0.0.1 is whoever is asking: it's a container asking its own loopback for a model server one network away. Browser JavaScript from another origin needs OLLAMA_ORIGINS — those calls get turned away at CORS, which looks identical from outside.
Is the Windows refusal different?
Same error text, different ceremony. The tray icon is the service, so an exit from the tray unlists the port. Set OLLAMA_HOST through System Properties → Environment Variables, fully quit and reopen the app, then test from PowerShell. Check the tray before you check the shield.
refused vs dropped, in kernel terms
Refusal is an active RST — the packet arrived, matched no listening socket, the kernel answered. A drop is silence: curl hangs into a timeout. An nftables REJECT rule can fake a refusal by sending RST itself — rare at home, real on servers.
- first published 2026-09-30; refreshed 2026-10-19
- documented behaviour: OS kernel, Ollama and Docker (loopback default, host-gateway flag); kernel refusal reproduced on a throwaway bench box with nothing listening
- record-read, not bench: no first-person pull or timing receipts — the repro box died twice before install finished
- default since first release: 127.0.0.1:11434, loopback only, no auth on the API