You tried to connect to Ollama and got:
Connection refused: http://localhost:11434
Here is how to fix it.
Fix 1: Start Ollama server
Ollama runs as a background service. Start it:
# Start Ollama server
ollama serve
# Or run in background
nohup ollama serve &
On macOS, Ollama runs automatically when installed. Check if it is running:
curl http://localhost:11434
# Should return: Ollama is running
Fix 2: Check port
Ollama defaults to port 11434. If it is in use:
# Check what's using port 11434
lsof -i :11434 # macOS
netstat -tlnp | grep 11434 # Linux
# Kill conflicting process
kill -9 <PID>
Or use a different port:
OLLAMA_HOST=0.0.0.0:11435 ollama serve
Fix 3: Fix Docker networking
If Ollama runs in Docker:
services:
ollama:
image: ollama/ollama
ports:
- "11434:11434" # Expose port
Then connect to http://localhost:11434 from your host.
For Docker-to-Docker communication:
services:
app:
# Connect to ollama service name, not localhost
environment:
- OLLAMA_URL=http://ollama:11434
Fix 4: Fix firewall
Firewall may block port 11434:
# Linux (UFW)
sudo ufw allow 11434/tcp
# Linux (firewalld)
sudo firewall-cmd --add-port=11434/tcp --permanent
sudo firewall-cmd --reload
# macOS: Check System Preferences > Security & Privacy > Firewall
Fix 5: Check Ollama is listening on all interfaces
By default, Ollama only listens on localhost:
# Listen on all interfaces (for remote access)
OLLAMA_HOST=0.0.0.0:11434 ollama serve
Fix 6: Check network configuration
If connecting remotely:
# Test connectivity
ping <server-ip>
# Test port
telnet <server-ip> 11434
# Or with nc
nc -zv <server-ip> 11434
Fix 7: Restart Ollama
# Kill existing Ollama
pkill ollama
# Start fresh
ollama serve
Still not working?
- Check Ollama logs โ
OLLAMA_DEBUG=1 ollama serve - Reinstall Ollama โ Sometimes a clean install fixes networking issues
- Check Docker logs โ
docker logs ollama - Try different port โ Some networks block default ports
FAQ
What port does Ollama use?
Ollama uses port 11434 by default. You can change it with OLLAMA_HOST=0.0.0.0:PORT ollama serve. Check your configuration if you are using a different port.
How do I know if Ollama is running?
Run curl http://localhost:11434. If it returns โOllama is runningโ, the server is up. If you get โconnection refusedโ, Ollama is not running or is listening on a different port.
Can I access Ollama from another machine?
Yes, but you need to set OLLAMA_HOST=0.0.0.0:11434 to listen on all interfaces, and ensure your firewall allows port 11434. See our Ollama Complete Guide for network setup details.
Related: Ollama Complete Guide ยท Ollama Slow Inference Fix ยท Ollama Model Not Found Fix ยท How to Run AI Locally ยท Best Local AI Models 2026