New reason of Connection refused error #2685

Closed
opened 2026-02-21 17:48:44 -05:00 by yindo · 0 comments
Owner

Originally created by @LaciliaExe on GitHub (Apr 26, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

I have read #2540 and similar issues where many people encountered Connection timeout or Connection refused errors when calling the Ollama API. Almost everyone is focusing on configuring Ollama to the port (0.0.0.0:11434) to make it accessible, but there is another issue that's been overlooked, which is that Docker containers cannot access the host's 11434 port. Although #2540 mentioned using http://host.docker.internal:11434/ as a solution, this only works for Windows and Mac OS; it is not suitable for Linux systems.

To fix this, you need to edit the docker-compose.yaml file as below image.

image

This means adding the statement in the red box at the subdirectory of the API, so that this problem can be solved.

I was able to identify the problem because my Ollama is deployed on Server A, while my Dify is deployed on another server, Server B. From Server B, I can use Python's requests library and browser URLs to call Ollama's API on Server A without any issues, but I'm unable to add models from Ollama to Dify, which is deployed in a Docker container on Server B. Since Ollama is clearly deployed within my network, the issue must be with Dify's configuration.

Originally created by @LaciliaExe on GitHub (Apr 26, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Provide a description of requested docs changes I have read #2540 and similar issues where many people encountered Connection timeout or Connection refused errors when calling the Ollama API. Almost everyone is focusing on configuring Ollama to the port (0.0.0.0:11434) to make it accessible, but there is another issue that's been overlooked, which is that **_Docker containers cannot access the host's 11434 port_**. Although #2540 mentioned using http://host.docker.internal:11434/ as a solution, this only works for Windows and Mac OS; it is not suitable for Linux systems. To fix this, you need to **_edit the docker-compose.yaml file as below image_**. ![image](https://github.com/langgenius/dify/assets/64969232/4997b87b-a2e6-43c9-9825-483254d5210b) This means **_adding the statement in the red box at the subdirectory of the API_**, so that this problem can be solved. I was able to identify the problem because my Ollama is deployed on Server A, while my Dify is deployed on another server, Server B. From Server B, I can use Python's requests library and browser URLs to call Ollama's API on Server A without any issues, but I'm unable to add models from Ollama to Dify, which is deployed in a Docker container on Server B. Since Ollama is clearly deployed within my network, the issue must be with Dify's configuration.
yindo added the 📚 documentation label 2026-02-21 17:48:44 -05:00
yindo closed this issue 2026-02-21 17:48:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#2685