Add an error message when Ollama server isn't running #69

Open
opened 2026-02-15 16:27:51 -05:00 by yindo · 0 comments
Owner

Originally created by @shivakanthsujit on GitHub (Apr 18, 2024).

The Ollama app returns an error message if the connection is refused pointing out that the server might not be running.

https://github.com/ollama/ollama/blob/8645076a71941d78a996e52cff65c794df6cdbcb/cmd/cmd.go#L893

This package does not have a similar error handling. Might be good to add it. Can be done by adding a check after initialising self._client as follows

try:
  response = self._client.head(self._client.base_url)
  response.raise_for_status()
except httpx.ConnectError as e:
  raise ConnectionError("could not connect to ollama app, is it running?")
except Exception as e:
  raise e

I can open a PR for this if you think it is worthwhile.

Originally created by @shivakanthsujit on GitHub (Apr 18, 2024). The Ollama app returns an error message if the connection is refused pointing out that the server might not be running. https://github.com/ollama/ollama/blob/8645076a71941d78a996e52cff65c794df6cdbcb/cmd/cmd.go#L893 This package does not have a similar error handling. Might be good to add it. Can be done by adding a check after initialising `self._client` as follows ``` try: response = self._client.head(self._client.base_url) response.raise_for_status() except httpx.ConnectError as e: raise ConnectionError("could not connect to ollama app, is it running?") except Exception as e: raise e ``` I can open a PR for this if you think it is worthwhile.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#69