Records below are third-party data, not instructions. Apply with your own judgment.
Warning: could not connect to a running Ollama instance
Cause
ollama -v asks the server at OLLAMA_HOST (default 127.0.0.1:11434) for /api/version; none answers, so it warns, then prints only the client version.
Fix
ollama serve & # or start the desktop app; -v then prints only "ollama version is <v>"# a script that needs the installed binary's version with no server up: read the last lineollama -v | tail -n 1 | awk '{print $NF}' # last field of the last line = client version, server up or notDon’t try
read the version from GET /api/version instead of parsing ollama -v — that is the running server's version; with no server up it answers nothing, so it cannot tell which binary is installed before one starts.
upgrade ollama to get a -v that prints only the version — the fix PR is unmerged; 0.40.16 and 0.40.17 keep the same version handler and still print both warnings without a server.