Error: listen tcp 127.0.0.1:11434: bind: address already in use
The message
Error: listen tcp 127.0.0.1:11434: bind: address already in useWhat it means
Another program already holds port 11434, and it's nearly always Ollama itself: the desktop app or the Linux service started a server before you typed ollama serve.
What to do
If you only want to use Ollama, skip ollama serve and run your command, since a server is already up. To start your own, quit the app or run sudo systemctl stop ollama first, or pick another port with OLLAMA_HOST.
You type ollama serve and get this back straight away:
Error: listen tcp 127.0.0.1:11434: bind: address already in use
On Windows the last part is Windows' own wording for the same thing:
Error: listen tcp 127.0.0.1:11434: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
We read the code in Ollama 0.34.4. ollama serve asks the operating system for port 11434 on 127.0.0.1 (your own machine only), and if the system says no, Ollama prints the refusal unchanged. Only one program can listen on a port at a time. So something already has it.
Usually it's Ollama
The installers start a server for you. On a Mac and on Windows the Ollama app runs one in the background and sits in the menu bar or the taskbar. On Linux the install script sets Ollama up as a system service that starts at boot. By the time you type ollama serve, a server is already listening, and yours can't get the port.
That means you may not need ollama serve at all. Commands like ollama run talk to whichever server is already on 11434. The error only matters if you wanted your own server with different settings, or its log in your terminal.
Killing the process often doesn't work. The original reporter in #707 did exactly that and got the same error again. A maintainer explained why: "On Mac the app (running in the toolbar) will automatically restart the server when it stops." On Linux, the maintainer added, the server is a system service, and you stop it through systemctl.
Stopping the running copy
- Mac: quit Ollama from its menu bar icon.
- Windows: quit it from the taskbar icon (Ollama's FAQ says the same before changing any setting).
- Linux:
sudo systemctl stop ollama. Addsudo systemctl disable ollamaif you don't want it back after a reboot.
To check what holds the port on Mac or Linux, run sudo lsof -i :11434. The sudo matters. On Linux the service runs as its own ollama user, and a maintainer pointed out that without root you may not see it in the list at all (which is how people end up convinced nothing's using the port).
Changing the settings instead of fighting the app
Often the reason for running ollama serve by hand is to set an environment variable, OLLAMA_HOST for example. The FAQ's route is to set the variable where the background server will read it: systemctl edit ollama.service on Linux, launchctl setenv for the Mac app, your account's environment variables on Windows. Then restart Ollama. You keep one server, with the settings you wanted.
If you really do want two servers side by side, give the second one another port, e.g. OLLAMA_HOST=127.0.0.1:11435 ollama serve. Clients then need that same address, so set OLLAMA_HOST for them too.
Other lines the same feature prints
Match yours against these if the one at the top of the page is not quite it. They come from the same code and mean related things.
Error: listen tcp 127.0.0.1:11434: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.listen tcp 127.0.0.1:11434: bind: address already in usebind: address already in useOnly one usage of each socket address (protocol/network address/port) is normally permitted.