You run ollama serve or start the Ollama.app on macOS and immediately see Error: listen tcp 127.0.0.1:11434: bind: address already in use (Linux/macOS) or bind: Only one usage of each socket address (Windows). The service never starts, and ollama run fails with a connection refused error. This happens most often after an OS update that restarted Ollama as a background service while a manual ollama serve was also running, or after a crash left the socket in TIME_WAIT state. It takes two minutes to fix once you know which process owns the port.
Common causes
Ordered by hit rate, highest first.
1. A previous Ollama process didn’t exit cleanly
The most common cause. A previous ollama serve process is still running in the background — visible in ps aux | grep ollama — even though the terminal session that started it was closed. The OS didn’t send SIGTERM because the terminal window was force-quit rather than closed normally.
How to spot it: Run lsof -i :11434 on macOS/Linux or netstat -ano | findstr :11434 on Windows. If the PID in the output belongs to ollama, it’s a stale Ollama instance.
2. Ollama system service and manual invocation running simultaneously
On Linux, installing Ollama via the install script creates a systemd service (ollama.service) that starts at boot. If you then run ollama serve manually in a terminal, the second instance fails because the first (the systemd service) already owns port 11434.
How to spot it: Run systemctl is-active ollama. If it returns “active,” the service is running. You don’t need to run ollama serve manually — just use ollama pull and ollama run directly.
3. Port 11434 bound by an unrelated process
Another application happens to be using port 11434. This is rare but possible with developer tools that bind dynamic port ranges.
How to spot it: Run lsof -i :11434 and check the process name. If it’s not ollama, you have a port conflict with another application.
4. TCP socket in TIME_WAIT after a crash
After a hard kill of the Ollama process (e.g., OOM killer, kill -9), the TCP socket enters TIME_WAIT for up to 60 seconds. The kernel holds the port while it waits for any in-flight packets to expire. Trying to restart Ollama immediately after a crash triggers this error.
How to spot it: Run ss -tn | grep 11434. If the state shows TIME-WAIT rather than LISTEN, wait 60 seconds and retry.
5. macOS Ollama.app and brew-installed ollama both running
Installing Ollama both as a macOS .app (from the website) and via Homebrew (brew install ollama) creates two independent Ollama binaries. If both are started (Ollama.app from the menu bar, ollama serve from the terminal), they conflict on port 11434.
How to spot it: Run which ollama and check if you also have Ollama.app in /Applications. If both exist, choose one and remove or disable the other.
6. OLLAMA_HOST set to 0.0.0.0 on a server where another Ollama instance binds to the same port
When OLLAMA_HOST=0.0.0.0:11434 is set, Ollama binds to all interfaces. A Docker container running Ollama or a second server process can conflict even if they’re on different network interfaces, because 0.0.0.0 captures everything.
How to spot it: Run echo $OLLAMA_HOST. If it’s 0.0.0.0:11434, check docker ps for any Ollama containers and netstat -tlnp | grep 11434 for all processes binding to that port.
Shortest path to fix
Step 1: Identify what owns port 11434
# macOS / Linux
lsof -i :11434
# Windows (PowerShell)
netstat -ano | findstr :11434
# Note the PID, then:
Get-Process -Id <PID>
Step 2: Kill the stale Ollama process
# If lsof shows an ollama process, kill it cleanly
pkill -f "ollama serve"
# Or by PID from lsof output:
kill -9 <PID>
# Linux: stop the systemd service instead of killing the process directly
sudo systemctl stop ollama
Step 3: Verify the port is free before restarting
# macOS / Linux — should return no output if the port is free
lsof -i :11434
# Wait a moment if the process was just killed
sleep 3
# Start Ollama again
ollama serve
Step 4: If you want Ollama to manage itself via systemd, don’t run it manually
# Enable and start the systemd service (don't also run ollama serve in terminal)
sudo systemctl enable --now ollama
sudo systemctl status ollama
# Verify it's listening
curl -s http://localhost:11434/api/version
Step 5: Change the Ollama port if 11434 is permanently occupied
# Run Ollama on a different port
export OLLAMA_HOST=127.0.0.1:11435
ollama serve &
# Update any client configs to point to the new port
# OpenWebUI: OLLAMA_BASE_URL=http://localhost:11435
# LangChain OllamaLLM: base_url="http://localhost:11435"
Step 6: For macOS Ollama.app conflicts, remove one installation
# Remove brew-installed ollama if using the .app
brew uninstall ollama
# Or remove the .app and use only brew
# Move /Applications/Ollama.app to Trash, then:
brew install ollama
Prevention
- Never run
ollama servemanually when the systemd service is enabled — useollama rundirectly and let the service handle the backend. - Add
sudo systemctl stop ollamato your pre-restart checklist if you regularly switch between manual and service-mode Ollama. - On macOS, choose either the .app or the brew/manual install — not both.
- Use
OLLAMA_HOST=127.0.0.1:11434(loopback only) unless you need LAN access, to reduce interference from Docker or other services. - If you must restart Ollama after a crash, wait 60 seconds for TIME_WAIT sockets to expire before restarting.
- Add an alias in your shell profile:
alias ollama-restart='pkill -f "ollama serve"; sleep 2; ollama serve &'. - Document the port in your project’s
.env.exampleso teammates know which port Ollama uses and can detect conflicts.
FAQ
Q: Can I run two Ollama instances on the same machine on different ports?
A: Yes. Export OLLAMA_HOST=127.0.0.1:11435 before starting the second instance. Each instance manages its own model pool, so both can serve different models simultaneously. Keep the OLLAMA_MODELS paths different if you want independent model storage.
Q: After killing the stale process, I still get “address already in use” for 30 seconds — why?
A: The TCP stack enters a TIME_WAIT or CLOSE_WAIT state after a connection is forcefully closed. Run ss -tn state time-wait | grep 11434 to confirm. The socket will release automatically; just wait 30-60 seconds before retrying.
Q: How do I make Ollama accessible on my LAN without using 0.0.0.0?
A: Set OLLAMA_HOST=192.168.1.X:11434 where 192.168.1.X is your machine’s LAN IP. This binds only to that interface, avoiding the all-interfaces binding that causes Docker conflicts.
Q: Ollama starts successfully but ollama run still says “connection refused” — why?
A: The ollama run CLI looks for the server at OLLAMA_HOST (default http://localhost:11434). If you started the server with a custom OLLAMA_HOST (e.g., port 11435), export the same OLLAMA_HOST in your terminal before running ollama run.