Skip to content

ollama python client wants OLLAMA_HOST or host #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TheDynomike
Copy link

@TheDynomike TheDynomike commented May 19, 2025

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:
#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.

@CLAassistant
Copy link

CLAassistant commented May 19, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic reviewed 2 files and found no issues. Review PR in cubic.dev.

@warmshao
Copy link
Collaborator

warmshao commented Jun 1, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants