Linux docker deploys dify and cannot invoke host local services #12226

Closed
opened 2026-02-21 19:06:27 -05:00 by yindo · 1 comment
Owner

Originally created by @dingjiahui00 on GitHub (Mar 27, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Linux docker deploys dify

linux source code deployment ollama

Use curl http://127.0.0.1:11434 in linux without error

After the ufw is enabled

Use http://172.17.0.1:11434 in dify
or
http://host.docker.internal:11434

Failed to link ollama

Error:

httpconnectionpool (host=172.17.0.1, port=11434): max retries exceeded with url:/cpi/chat (Caused by NewConnectionError ('<urllib3.connection.HTTPConnection object at 0x7f8562812c20>: fail to establish a new connection:[Errno 111] Connection refused'))

✔️ Expected Behavior

success

Actual Behavior

Error:
httpconnectionpool (host=172.17.0.1, port=11434): max retries exceeded with url:/cpi/chat (Caused by NewConnectionError ('<urllib3.connection.HTTPConnection object at 0x7f8562812c20>: fail to establish a new connection:[Errno 111] Connection refused'))

Originally created by @dingjiahui00 on GitHub (Mar 27, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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 this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Linux docker deploys dify linux source code deployment ollama Use curl http://127.0.0.1:11434 in linux without error After the ufw is enabled Use http://172.17.0.1:11434 in dify or http://host.docker.internal:11434 Failed to link ollama Error: httpconnectionpool (host=172.17.0.1, port=11434): max retries exceeded with url:/cpi/chat (Caused by NewConnectionError ('<urllib3.connection.HTTPConnection object at 0x7f8562812c20>: fail to establish a new connection:[Errno 111] Connection refused')) ### ✔️ Expected Behavior success ### ❌ Actual Behavior Error: httpconnectionpool (host=172.17.0.1, port=11434): max retries exceeded with url:/cpi/chat (Caused by NewConnectionError ('<urllib3.connection.HTTPConnection object at 0x7f8562812c20>: fail to establish a new connection:[Errno 111] Connection refused'))
yindo added the 🐞 bug label 2026-02-21 19:06:27 -05:00
yindo closed this issue 2026-02-21 19:06:27 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 27, 2025):

Hello @dingjiahui00! I'm here to help you with any bugs, questions, or contributions you have for Dify. Let's work together to resolve your issue.

I found a similar discussion that might help resolve your issue. In a previous case, users encountered a "Connection refused" error when trying to access services from a Docker container on Linux. The solution involved modifying the Docker configuration to allow access to the host's network services.

Here are the steps you can try:

  1. Use host.docker.internal: Replace 127.0.0.1 with host.docker.internal in your configuration. This allows the Docker container to access services running on the host machine. The full URL should be http://host.docker.internal:11434.

  2. Edit Docker Compose File: If you're using Docker Compose, you might need to edit the docker-compose.yaml file to ensure that the necessary ports are exposed and accessible. This might involve adding specific network configurations to allow the container to communicate with the host.

  3. Check UFW Settings: Since you mentioned enabling UFW (Uncomplicated Firewall), ensure that it is configured to allow traffic on the necessary ports. You can do this by running:

    sudo ufw allow 11434
    
  4. Unset Proxy Variables: If you have any system proxy environment variables set, try unsetting them:

    unset HTTP_PROXY
    unset HTTPS_PROXY
    

These steps should help resolve the connection issues you're experiencing. For more detailed guidance, you can refer to the similar discussion here [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 27, 2025): <!-- Greeting --> Hello @dingjiahui00! I'm here to help you with any bugs, questions, or contributions you have for Dify. Let's work together to resolve your issue. <!-- Answer --> I found a similar discussion that might help resolve your issue. In a previous case, users encountered a "Connection refused" error when trying to access services from a Docker container on Linux. The solution involved modifying the Docker configuration to allow access to the host's network services. Here are the steps you can try: 1. **Use `host.docker.internal`**: Replace `127.0.0.1` with `host.docker.internal` in your configuration. This allows the Docker container to access services running on the host machine. The full URL should be `http://host.docker.internal:11434`. 2. **Edit Docker Compose File**: If you're using Docker Compose, you might need to edit the `docker-compose.yaml` file to ensure that the necessary ports are exposed and accessible. This might involve adding specific network configurations to allow the container to communicate with the host. 3. **Check UFW Settings**: Since you mentioned enabling UFW (Uncomplicated Firewall), ensure that it is configured to allow traffic on the necessary ports. You can do this by running: ```bash sudo ufw allow 11434 ``` 4. **Unset Proxy Variables**: If you have any system proxy environment variables set, try unsetting them: ```bash unset HTTP_PROXY unset HTTPS_PROXY ``` These steps should help resolve the connection issues you're experiencing. For more detailed guidance, you can refer to the similar discussion [here](https://github.com/langgenius/dify/discussions/3912) <sup>[[1]](https://github.com/langgenius/dify/discussions/3912)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e746580b-a11f-4c33-ab7c-838123238a2b?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12226