Ollama connection refused from other hosts: it was bound to 127.0.0.1

2026-12-01来源 dev.toEnglish
Ollama connection refused from other hosts: it was bound to 127.0.0.1

All the local AI in my homelab runs on one box. It's a Pop!_OS machine with an RTX 2060, so 6 GB of VRAM, running Ollama. My agents, a user-modelling service and a few automations all call it over the network.

Over a few months it "went down" on me in four different ways. Every time, the box itself looked fine. This is the list, starting with the dumbest one, because it's the one most people will hit.

A four-step checklist for when Ollama looks down: refused from other hosts, slow with size_vram 0, hanging behind a big job, and stuck on an old version

1. Connection refused, but only from other machines

By 8 July 2026 this kept happening: clients failing with "connection refused" or HTTP 000. Meanwhile, on the box:

  • ping: fine
  • SSH: fine
  • systemctl is-active ollama: active

Everything said healthy, and nothing could talk to it.

The cause: Ollama binds to 127.0.0.1:11434 by default. Unless you set OLLAMA_HOST, it only listens on localhost. So from the box itself, every test passes. From anywhere else, refused.

The fix is a systemd drop-in, not an edit to the unit file:

sudo mkdir -p /etc/systemd/system/ollama.service.d printf '[Service]\nEnvironment=OLLAMA_HOST=0.0.0.0:11434\n' | \ sudo tee /etc/systemd/system/ollama.service.d/10-host.conf sudo systemctl daemon-reload && sudo systemctl restart ollama 

Then check it's listening on everything, not just loopback:

ss -tln | grep 11434 # want *:11434, not 127.0.0.1:11434 

Test from a client, not from the box. curl -m8 http://<box>:11434/api/tags giving you a 200 is the only check that counts here.

Why a drop-in? Because the Ollama installer rewrites ollama.service every time you upgrade, and anything you put in that file goes with it. It doesn't touch ollama.service.d/. I've upgraded it several times since (including 0.30.8 to 0.32.9 on 12 August, 0.32.13 on 16 August and 0.34.4 on 29 September) and checked the drop-ins after each of those. They survived every time.

Fair warning, 0.0.0.0 means anything that can reach the box can use your models. Mine sits on a home LAN behind a firewall. Don't do this on something with a public IP.

2. It answers, but it's painfully slow

On 17 July everything that used the box got really slow. It was answering, just glacially.

/api/ps told me why. The model loaded at the time showed size_vram=0. All 13.3 GB of it was running on the CPU. The GPU was doing nothing.

Then nvidia-smi:

Failed to initialize NVML: Driver/library version mismatch 

The NVIDIA driver package had been upgraded, but the kernel module loaded in memory was still the old one. The loaded module was 580.159.03, the userspace library was 580.173. /var/run/reboot-required was set, and the box had been up for 10 weeks. Ollama couldn't use the GPU, so it quietly fell back to CPU. No error to the client, just slow.

The fix is a reboot. You can't really rmmod your way out on a desktop box, because the module was held open by Xorg (the desktop), ComfyUI (my image generation), and an idle "unsloth studio" server that had been holding a GPU handle for 63 days doing nothing.

And at that point my automation didn't have root on that box, so the reboot had to wait for me. I've sorted that since.

And it happened again, the morning I wrote this

On 18 October 2026, while I was checking facts for this post, I ran the same commands and got the same error. Real output:

Terminal output from 18 October 2026: before the reboot nvidia-smi fails with a driver/library mismatch and the model has size_vram 0; after the reboot the driver loads and the model is fully in VRAM

Same story. The apt history showed a full-upgrade at midnight on 17 October that moved the NVIDIA packages from 580.173.02 to 580.178.04. The kernel was still running 580.173.02. The main model, qwen3.5-64k, showed size_vram: 0. After a reboot later that morning, the module matched, nvidia-smi worked, and the next model that loaded was entirely in VRAM.

So the lesson isn't "I fixed it in July". It's that any unattended driver upgrade on a GPU box is a silent CPU fallback waiting for a reboot. Nothing errors. It just gets slow, and slow doesn't page anyone.

What I'd check, in this order: /api/ps for size_vram, then nvidia-smi, then whether /var/run/reboot-required exists.

3. A request that just hangs

On 29 September I upgraded Ollama to 0.34.4 and a test request hung for 7 minutes. Obvious conclusion: the upgrade broke it.

It hadn't. A scheduled job of mine was running a 17 GB model (qwen3.8:27b, far too big for a 6 GB card, so it was on the CPU at around 1,100% CPU) at the same time. With a job like that running, every other request queues behind it.

So before blaming Ollama, check /api/ps to see what's loaded, and top to see what's eating the CPU. I've written separately about the nastier version of this, where a model pinned with keep_alive: -1 blocked every other model forever: Ollama keep_alive -1 hangs every other model.

4. It never updates

This one isn't an outage, but it bit me on 12 August. A model I wanted needed a newer Ollama, and mine was two versions behind.

My patching automation never touched it, and it couldn't. Ollama installed with curl -fsSL https://ollama.com/install.sh | sh isn't an apt package:

dpkg -S /usr/local/bin/ollama # no path found 

unattended-upgrades only ever touches apt. So Ollama sits on whatever version you installed until you run the installer again. Adding the box to more patching wouldn't help either. It's a whole category that patching can't see. Same goes for anything else you installed with curl | sh.

Upgrading is the same line with a pinned version:

curl -fsSL https://ollama.com/install.sh | OLLAMA_VERSION=0.32.9 sh 

Pin it rather than taking latest. Then rolling back is the same line with the old number.

Funny thing is, the driver problem in section 2 is the opposite. The apt side does update on its own, and that's what broke it. One thing never updates, the other updates and then needs a reboot nobody does.

What I'd do differently

  • Test from a client, always. Every check I ran on the box itself in July said healthy.
  • Put config in drop-ins. Installers rewrite unit files. They leave .service.d/ alone.
  • Watch size_vram, not just "is it up". A GPU box that's fallen back to CPU is up. It's just useless.
  • Reboot after driver upgrades, or don't auto-upgrade the driver. Either is fine. Auto-upgrading and never rebooting is the one combination that breaks quietly.
  • Know which of your tools apt can't see. Write the list down. Mine is longer than I thought.

What's the first thing you check when your local LLM "goes down"? I start with /api/ps now.

🤖 Drafted with AI assistance from my own homelab notes, logs and repos, and fact-checked against them before publishing.

原文:https://www.a8q9.cn/en/article/ollama-connection-refused-from-other-hosts-it-was-bound-to-127-0-0-1-077965.html

相关文章