PromtEngineer / PromtEngineer/localGPT

Docker connection issue between rag-api container and local Ollama service

Open
#856 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
22.2k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

I am encountering a persistent error in the logs of the rag-api container. Although the initialization seems correct at first — models are loaded and the endpoints respond with 200 — the application repeatedly throws the following error:
⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError(... Failed to establish a new connection: [Errno 111] Connection refused))

This indicates that the rag-api service is trying to contact Ollama at 172.18.0.1:11434 (likely the Docker gateway to the host), but the connection is consistently refused.
However, GET requests to /models return a 200 status code, suggesting that the local Ollama API is functional from the host, but inaccessible from within the container.

Technical context:
I am running on Windows with Ollama already installed locally.
I have not restarted ollama serve because it returns the following error:
Error: listen tcp 127.0.0.1:11434: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

This makes sense since the Ollama service is already running.

I have not reinstalled Ollama via curl because it was already present on my machine.

The rag-api container tries to reach Ollama via the address 172.18.0.1:11434, but Ollama is only listening on 127.0.0.1 (the loopback interface). The host’s loopback interface (127.0.0.1) is not accessible from a Docker container, even when attempting to route through the Docker gateway (172.18.0.1).

Error :

Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190558590>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190369110>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190549490>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919036b2d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190db7410>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190548050>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054c2d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f91d8bfc1d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190558090>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054b950>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190369090>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054ecd0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919055ba90>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f91905489d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f91905238d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054e3d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f91905228d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f91905493d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9190558e50>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054c6d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919036c090>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054aa10>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054ba90>: Failed to establish a new connection: [Errno 111] Connection refused'))
rag-api | ⚠️ Could not get Ollama models: HTTPConnectionPool(host='172.18.0.1', port=11434): Max retries exceeded with url: /api/tags (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f919054cc90>: Failed to establish a new connection: [Errno 111] Connection refused'))

Image

Image

Contributor guide

Open the contributing guide

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

Start by reproducing the Windows setup with the rag-api container and local Ollama service, then compare access to /models and Ollama's /api/tags endpoint from the host and container. Investigate the reported 172.18.0.1:11434 connection path and the Ollama 127.0.0.1 binding. Done means the container can retrieve models without repeated connection-refused errors, with the relevant setup documented or covered by a reproducible check.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, ollama, python
Domain
backend, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.