SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
AI New Added 8 September 2026

Ollama: connection refused on localhost:11434

The client could not reach the Ollama server. Either the service is not running, or it is running but bound to loopback only, which is what breaks calls from a container or another machine even though the same command works on the host.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Is it up?
curl -s http://localhost:11434/api/tags | jq .
systemctl status ollama

# Bind beyond loopback for containers or other hosts
sudo systemctl edit ollama
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
sudo systemctl restart ollama

# From a container on Docker Desktop, the host is not localhost
OLLAMA_HOST=http://host.docker.internal:11434

How to diagnose AI errors

AI and LLM errors cluster into four families: quota and rate limiting (429s, insufficient_quota), context window overflow (the prompt plus the requested completion exceeds the model's limit), accelerator memory (CUDA OOM, KV-cache exhaustion), and content policy (a refusal or safety stop rather than a transport failure). The first thing to establish is which family you are in, because the fixes have nothing in common: a 429 wants backoff and a quota increase, a context overflow wants truncation or chunking, and a CUDA OOM wants a smaller batch or a quantised model.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Read the error body, not just the status code. Providers put the real reason in a JSON error.type / error.code field: rate_limit_exceeded and insufficient_quota are both HTTP 429 but mean completely different things.
  2. Count your tokens before you send. Use the provider's tokenizer (tiktoken, Anthropic's count-tokens endpoint) rather than guessing from character length, and remember that max_tokens for the response is reserved inside the context window.
  3. For local inference, watch VRAM live with nvidia-smi -l 1 while the request runs. Memory that peaks during the forward pass rather than at load time points at batch size or sequence length, not at model weights.
  4. Distinguish a refusal from a failure. A stop_reason of refusal, or a finishReason of SAFETY, is a successful HTTP 200. Retrying identical input will produce the same result.
  5. Always implement exponential backoff with jitter and honour the retry-after header. Most production LLM incidents are self-inflicted retry storms.

Tools worth reaching for

  • tiktoken
  • nvidia-smi
  • curl -i
  • provider status pages

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

docs.ollama.com

Related AI errors

See all 35 AI errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.