Error: listen tcp 127.0.0.1:11434: bind: address already in use from ollama serve on Linux means a server already owns the port, and on a script install it is the ollama systemd service. You do not need a second one: ollama list, ollama run and your own code already reach the running server.

Confirm it with systemctl is-active ollama. If you ran serve to watch the server's log, read the service's journal instead; if you really want another server, give it its own port with OLLAMA_HOST.

The error

$ HOME=/tmp/fix3-owsl/c4home ollama serve
...
Error: listen tcp 127.0.0.1:11434: bind: address already in use

The trimmed lines announce a new key pair: ollama serve creates ~/.ollama/id_ed25519 before it tries the port, so even a failed run leaves that folder in your home. Pointing HOME at a scratch folder kept it out of the real one here.

Why it happens

The install script registers ollama.service, which runs /usr/local/bin/ollama serve as the ollama user and starts with the system; under WSL with systemd enabled, that means whenever the distribution starts. Its address is the default, 127.0.0.1:11434. Typing ollama serve starts a second copy that asks the kernel for the same address and port, only one listener is allowed, and the second copy exits with code 1. The service is not disturbed.

ss names the owner when run as root. Here it reported users:(("ollama",pid=175,fd=3)), and systemctl show -p MainPID ollama printed MainPID=175: the service itself. Windows reports the same collision in different words, covered in 'Only one usage of each socket address'.

The fix

Use the server that is already running:

$ systemctl is-active ollama
active
$ ollama list
NAME                       ID              SIZE      MODIFIED
llama3.1:8b                46e0c10c039e    4.9 GB    13 days ago
...
$ curl -s http://127.0.0.1:11434/api/version
{"version":"0.34.2"}

For the log that serve would have printed, journalctl -u ollama -n 3 --no-pager showed the service's latest request lines. If you need a second server, for a test or another model folder, start it on its own port:

$ HOME=/tmp/fix3-owsl/c4home OLLAMA_MODELS=/tmp/fix3-owsl/c4models OLLAMA_HOST=127.0.0.1:15999 ollama serve > c4-serve.log 2>&1 &
$ OLLAMA_HOST=127.0.0.1:15999 ollama list
NAME    ID    SIZE    MODIFIED
$ curl -s http://127.0.0.1:15999/api/version
{"version":"0.34.2"}

Its log said Listening on 127.0.0.1:15999 (version 0.34.2), and plain ollama list still reached the service. The list is empty because the service's models live under /usr/share/ollama, owned by the ollama user, and this server was given a folder of its own. To run the only server in the foreground for debugging, stop the service first with sudo systemctl stop ollama; that was not exercised here.

How it was reproduced

Ollama 0.34.2 on Ubuntu 24.04.4 under WSL2, installed with the official script and running as ollama.service (enabled, active). ollama serve was run once as the normal user; it failed at once and the service kept serving. The second server ran on 127.0.0.1:15999, answered both checks, and was stopped with kill by its recorded process id, after which the service was still active.

Frequently asked

Do I need to run ollama serve after installing Ollama on Linux?
Not if the install script set up the systemd service. The service starts the server at boot on 127.0.0.1:11434; check it with systemctl is-active ollama, then use ollama list or ollama run directly.
How do I see what is using port 11434 on Linux?
Run sudo ss -ltnp 'sport = :11434'. As root it shows the process name and pid of the listener; compare that pid with systemctl show -p MainPID ollama to confirm it is the service.
How do I see the Ollama server log on Linux?
Read the service's journal with journalctl -u ollama, adding -n to limit the lines or -f to follow it live. Running ollama serve by hand only shows the log of a server you start yourself, and it cannot start while the service holds the port.

More decoded errors in the Fixes category, or see how the service is set up in Ollama on a Linux server, done properly.