Help with proxy issues for configuring models #6126

Closed
opened 2026-02-21 18:14:11 -05:00 by yindo · 1 comment
Owner

Originally created by @nickboyabc on GitHub (Oct 16, 2024).

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

0.9.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Help with proxy issues for configuring models
1.The host in China is ubuntu system, it will report error when configure offshore model;

  1. The host has been configured with a system proxy via clash, the port number is 7078, and it can pull the repository code to update the dedify version normally.

  2. I have try to configure the following in /etc/systemd/system/docker.service.d/http-proxy.conf:
    [Service]
    Environment="HTTP_PROXY=http://127.0.0.1:7078”
    Environment="HTTPS_PROXY=http://127.0.0.1:7078”
    Environment="NO_PROXY=localhost,127.0.0.1”

  3. Restart the service:
    sudo systemctl daemon-reload
    sudo systemctl restart docker

  4. Verify the proxy configuration: sudo systemctl show --property=Environment docker
    Environment=HTTP_PROXY=http://127.0.0.1:7078/ HTTPS_PROXY=http://127.0.0.1:7078/ NO_PROXY=localhost,127.0.0.1

  5. Finally, in dedify, the model still reports an error when configuring the model:
    An error occurred during credentials validation: HTTPSConnectionPool(host='qianwen.wa***.workers.dev', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f2988899ea0>, 'Connection to qianwen.waichenli.workers.dev timed out. (connect timeout=10)')))

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @nickboyabc on GitHub (Oct 16, 2024). ### 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 0.9.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Help with proxy issues for configuring models 1.The host in China is ubuntu system, it will report error when configure offshore model; 2. The host has been configured with a system proxy via clash, the port number is 7078, and it can pull the repository code to update the dedify version normally. 3. I have try to configure the following in /etc/systemd/system/docker.service.d/http-proxy.conf: [Service] Environment="HTTP_PROXY=http://127.0.0.1:7078” Environment="HTTPS_PROXY=http://127.0.0.1:7078” Environment="NO_PROXY=localhost,127.0.0.1” 4. Restart the service: sudo systemctl daemon-reload sudo systemctl restart docker 5. Verify the proxy configuration: sudo systemctl show --property=Environment docker Environment=HTTP_PROXY=http://127.0.0.1:7078/ HTTPS_PROXY=http://127.0.0.1:7078/ NO_PROXY=localhost,127.0.0.1 6. Finally, in dedify, the model still reports an error when configuring the model: An error occurred during credentials validation: HTTPSConnectionPool(host='qianwen.wa***.workers.dev', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f2988899ea0>, 'Connection to qianwen.waichenli.workers.dev timed out. (connect timeout=10)'))) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 18:14:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 16, 2024):

I found some similar issues and discussions that might help you resolve the proxy issues you're facing with configuring models on a self-hosted Dify version 0.9.2 using Docker:

  1. Connection Error When Setting Up Model Provider: This discussion might provide insights into connection issues when setting up model providers [1].

  2. Unable to Use External HTTP Requests: This discussion addresses issues with external HTTP requests after installing Dify with Docker, which might be relevant to your proxy configuration [2].

  3. How to Set Proxy for Built-in Tools: This discussion could offer guidance on setting up proxies for tools within Dify [3].

To resolve your specific issue, ensure that the proxy settings are correctly configured for Docker containers. Here are some steps you can take:

  • Expose Services to the Network: If you're using Docker, localhost refers to the container itself. Use the Docker host's IP address or host.docker.internal to expose services to the network.

  • Modify Base URL: Change the base URL in Dify settings from http://localhost:11434 to http://host.docker.internal:11434 or use the local network IP address of the host machine.

  • Set Environment Variables for Proxy: Ensure that the HTTP_PROXY and HTTPS_PROXY environment variables are set correctly. If the proxy is on the host machine, use the host's IP address accessible from within the Docker container, such as http://192.168.1.100:7890.

  • Set Environment Variables for Services: If services like Ollama are run as systemd services, set the OLLAMA_HOST environment variable to 0.0.0.0 to bind the service to all network interfaces [4][5].

By following these steps, you should be able to resolve the connection timeout error and allow the Docker container to access the services through the configured proxy.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 16, 2024): <!-- Answer --> I found some similar issues and discussions that might help you resolve the proxy issues you're facing with configuring models on a self-hosted Dify version 0.9.2 using Docker: 1. **Connection Error When Setting Up Model Provider**: This discussion might provide insights into connection issues when setting up model providers <sup>[[1]](https://github.com/langgenius/dify/discussions/7839)</sup>. 2. **Unable to Use External HTTP Requests**: This discussion addresses issues with external HTTP requests after installing Dify with Docker, which might be relevant to your proxy configuration <sup>[[2]](https://github.com/langgenius/dify/discussions/8423)</sup>. 3. **How to Set Proxy for Built-in Tools**: This discussion could offer guidance on setting up proxies for tools within Dify <sup>[[3]](https://github.com/langgenius/dify/discussions/7833)</sup>. To resolve your specific issue, ensure that the proxy settings are correctly configured for Docker containers. Here are some steps you can take: - **Expose Services to the Network**: If you're using Docker, `localhost` refers to the container itself. Use the Docker host's IP address or `host.docker.internal` to expose services to the network. - **Modify Base URL**: Change the base URL in Dify settings from `http://localhost:11434` to `http://host.docker.internal:11434` or use the local network IP address of the host machine. - **Set Environment Variables for Proxy**: Ensure that the `HTTP_PROXY` and `HTTPS_PROXY` environment variables are set correctly. If the proxy is on the host machine, use the host's IP address accessible from within the Docker container, such as `http://192.168.1.100:7890`. - **Set Environment Variables for Services**: If services like Ollama are run as systemd services, set the `OLLAMA_HOST` environment variable to `0.0.0.0` to bind the service to all network interfaces <sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/en/development/models-integration/ollama.md)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/getting-started/install-self-hosted/environments.md)</sup>. By following these steps, you should be able to resolve the connection timeout error and allow the Docker container to access the services through the configured proxy. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6126