ollama / ollama/ollama-python

Add an error message when Ollama server isn't running

Open Beginner friendly
#120 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.5k
Forks
1.2k
Avg merge
4m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate where self._client is initialized and review the connection handling around its base_url. Confirm the expected httpx.ConnectError behavior and add a clear message indicating that the Ollama app may not be running; done means connection-refused errors provide that message without changing other exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.