web-ui icon indicating copy to clipboard operation
web-ui copied to clipboard

ollama python client wants OLLAMA_HOST or host

Open TheDynomike opened this issue 6 months ago • 1 comments

PROBLEM:

Running ollama server via docker container on my Ubuntu headless server

File "/usr/local/lib/python3.11/site-packages/ollama/_client.py", line 124, in _request_raw
raise ConnectionError(CONNECTION_ERROR_MESSAGE) from None
ConnectionError: Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible.

SOLUTION:

I wasn't able to identify where the code could pass in the expected host here: https://github.com/ollama/ollama-python/blob/main/ollama/_client.py#L94

so I opted for the "or" OLLAMA_HOST fix which is a straightforward addition to the env vars.

Related issue: https://github.com/browser-use/web-ui/issues/595


Summary by cubic

Added OLLAMA_HOST environment variable to support Python clients that expect this variable for connecting to the Ollama server.

  • Dependencies
    • Updated .env.example and docker-compose.yml to include OLLAMA_HOST with a default value.

TheDynomike avatar May 19 '25 21:05 TheDynomike

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 19 '25 21:05 CLAassistant

I don't think this is the reason why Ollama can't be connected. Your changes will affect the use of Ollama by non-Docker users, which is unacceptable. Have you tried connecting to Ollama in Docker by http://host.docker.internal:11434?

warmshao avatar Jun 01 '25 15:06 warmshao