RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Troubleshooting Local AI
  6. /Ch. 7
Troubleshooting Local AI

07. API Connection Refused

Chapter 7 of 15 · 20 min
KEY INSIGHT

"Connection refused" means the TCP handshake completed but no process was listening on that port. The process is either not running, bound to the wrong interface, or a firewall is dropping packets before they reach the application.

Checklist Before Assuming a Code Bug

  1. Is the server process running? ps aux | grep ollama or ps aux | grep vllm
  2. Is the correct port in use? sudo lsof -i :11434
  3. Is the firewall allowing connections? sudo ufw status or sudo iptables -L
  4. Is the server binding to the right interface? Some servers bind to 127.0.0.1 by default, accepting only local connections.

Common Causes

Wrong Host Binding

Ollama binds to 127.0.0.1 by default. External access requires:

# Check current binding
sudo lsof -i :11434 | grep LISTEN

# If bound to 127.0.0.1, restart with correct host
OLLAMA_HOST="0.0.0.0" ollama serve

Port Already in Use

# Find what's using the port
sudo lsof -i :8080
# Kill the process
sudo kill $(sudo lsof -t -i :8080)

Docker Network Isolation

# Check if container can reach host
docker exec -it <container_id> curl http://host.docker.internal:8080/health

# Run container with host network
docker run --network host your-ai-service

TLS Certificate Issues

# Test HTTP (non-TLS) connectivity
curl http://localhost:11434/api/tags
# Test with verbose output
curl -v http://localhost:11434/api/tags

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Start an Ollama server, verify it works locally, then deliberately misconfigure it to bind to 127.0.0.1 while attempting to connect from the host machine. Observe the exact error message. Restore correct configuration.

← Chapter 6
Slow Inference
Chapter 8 →
Docker Issues