Error: could not connect to ollama server, run 'ollama serve' to start it means the ollama command found nothing listening at the address it uses: 127.0.0.1:11434, unless OLLAMA_HOST says otherwise. Either no server is running, or the client is looking in the wrong place; systemctl status ollama and echo $OLLAMA_HOST tell you which.

If the service is active and OLLAMA_HOST is set, unset it and run the command again. If nothing is running, start a server where the client looks. You rarely need the literal advice in the message: on a script install the server is a systemd service, not something you start by hand.

The error

$ OLLAMA_HOST=127.0.0.1:15999 ollama list
Error: could not connect to ollama server, run 'ollama serve' to start it
$ OLLAMA_HOST=127.0.0.1:15999 ollama --version
Warning: could not connect to a running Ollama instance
Warning: client version is 0.34.2

Why it happens

Every ollama subcommand except serve is a client: it sends HTTP requests to a server and does nothing on its own. ollama list, ollama ps and ollama run all printed the line above and exited with code 1 when the connection was refused; curl to the same address said Couldn't connect to server, the same fact in curl's words. ollama --version is gentler, printing two warnings and exiting 0, which makes it a quick test.

Here nothing listened on port 15999, which is exactly the state a stopped service leaves on 11434; the client cannot tell the two apart. The other road is an OLLAMA_HOST exported in a shell or a profile: every command in that shell goes to that address. Older releases worded the same refusal could not connect to ollama app, is it running? (the source at tag v0.5.7 has it; the cause is the same). Under WSL, pointing the client at the Windows host's address to reach the Ollama app there did not produce this error at all: the command hung until a 20-second timeout stopped it. The Windows app was listening on 127.0.0.1 only, so that is not a route to it either way.

The fix

Check the service, then the variable:

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

If OLLAMA_HOST comes back after a new terminal, look for it in ~/.bashrc or ~/.profile. If the service is not active, sudo systemctl start ollama is the usual cure; it was not exercised here because the service was running and not ours to stop. To prove the other half, a server was started where the client was looking:

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

The same command that failed now answers. The list is empty because OLLAMA_MODELS gave the test server a new, empty model folder, and HOME kept the key pair it generates on first start out of the real home directory.

How it was reproduced

Ollama 0.34.2 installed as a systemd service on Ubuntu 24.04.4 under WSL2, active throughout. Rather than stop it, the client was made unreachable by address: OLLAMA_HOST pointed at 127.0.0.1:15999, where ss -ltn showed no listener. The fix was confirmed twice: unsetting the variable brought back the service's model list, and a server started by hand on 15999 answered the identical command until it was stopped by its process id.

Frequently asked

How do I check if Ollama is running on Linux?
Run systemctl is-active ollama, or systemctl status ollama for more detail, to see the service. Then curl http://127.0.0.1:11434/api/version; a running server answers with its version as JSON.
What does 'could not connect to ollama app, is it running?' mean?
It is the older wording of the same error. The Ollama source at tags v0.3.0, v0.5.7 and v0.6.0 has that message for a client that cannot reach the server; release 0.34.2 prints could not connect to ollama server, run 'ollama serve' to start it. The cause and the fix are the same.
Why does ollama work in one terminal but not in another?
Compare echo $OLLAMA_HOST in both. The client reads OLLAMA_HOST from the environment, so a value exported in one shell or a profile file sends that shell's commands to a different address. unset OLLAMA_HOST returns to 127.0.0.1:11434.

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