Warning: could not connect to a running Ollama instance from
ollama --version means the client reached no Ollama server on the address it
uses; the line after it, Warning: client version is ..., is the client's own
version. Start the server or fix OLLAMA_HOST, and ollama --version
prints the server's version instead.
The command still exits with 0, so a script that only checks the exit code does not notice.
Read the first line: ollama version is ... means a server answered.
The error
With OLLAMA_HOST pointing at a port where nothing listened:
PS> $env:OLLAMA_HOST = "127.0.0.1:15199"
PS> ollama --version
Warning: could not connect to a running Ollama instance
Warning: client version is 0.40.14
exit=0
Before the test, Get-NetTCPConnection -State Listen -LocalPort 15199 counted 0
listeners on that port.
Why it happens
ollama --version printed two different things in this test depending on what
was on the other end. With nothing listening, it printed the two warnings above. With an
Ollama server of another version, it printed the server's version first and the client's
version as a warning:
PS> $env:OLLAMA_HOST = "127.0.0.1:15960"
PS> ollama --version
ollama version is 0.40.8
Warning: client version is 0.40.14
exit=0
PS> curl.exe -s http://127.0.0.1:15960/api/version
{"version":"0.40.8"}
With the default address, where the Windows app of the same version runs, it printed one line and no warning. So the second warning on its own is not an error: it appeared both when no server answered and when the server was older than the client. The first warning is the one that says no server answered.
The fix
Point the client at an address where Ollama runs, or clear the variable to use the default:
PS> Remove-Item Env:OLLAMA_HOST
PS> ollama --version
ollama version is 0.40.14
exit=0
When you
see the version-mismatch pair instead, the client and the server are separate installs;
update the older one if the difference matters to you. In this test ollama list from
the 0.40.14 client against the 0.40.8 server printed its (empty) table and exited with 0.
How it was reproduced
Windows client 0.40.14 in Windows PowerShell 5.1, with OLLAMA_HOST set in the
script's own process. The second server was
docker run -d --name fix9-olc-srv -p 127.0.0.1:15960:11434 ollama/ollama
(server 0.40.8). Port 15199 had no listener. The container was the test's own and was
removed afterwards. In the same session, ollama list against port 15199 did
not print this warning; it printed Error: timed out waiting for server to start,
the case covered in
timed out waiting for
server to start.
Frequently asked
- What does Warning: could not connect to a running Ollama instance mean?
- ollama --version reached no Ollama server on the address it uses, so it printed only the client's version. Start the server or correct OLLAMA_HOST and run it again.
- What does Warning: client version is mean in ollama --version?
- It is the version of the ollama program you ran. In the test it appeared after the could-not-connect warning and also after the server's version when the server was 0.40.8 and the client 0.40.14.
- Does ollama --version fail when the server is not running?
- No. In the test it exited with code 0 and printed two warnings. Check the first line: ollama version is ... means a server answered.
More decoded errors in the Fixes category. A different
message, could not connect to ollama server, is covered in
its own post for Linux
and WSL.