Host using proxy and use docker deploy Dify #13229

Closed
opened 2026-02-21 19:11:11 -05:00 by yindo · 2 comments
Owner

Originally created by @pzookloop on GitHub (Apr 22, 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.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

hi, everyone, please help me:
My operation system is Ubuntu 24.04 and Docker Compose version is v2.34.0, Dify version is 1.2.0.
I deploy ollama and dify with docker and expected Dify to be able to access the models in Ollama.
I deployed it according to the following steps:

  1. In all Dify services that do not require a proxy, I exclude the proxy by setting the http_proxy & https_proxy environment variable to an empty string.
  2. start Dify with docker compose up -d
  3. This is my ollama deployment file:
services:
  ollama:
    image: ollama/ollama
    runtime: nvidia
    container_name: ollama
    volumes:
      - ./ollama:/root/.ollama
    healthcheck:
      test: ["CMD", "ollama", "list"]
      interval: 10s
      timeout: 30s
      retries: 5
      start_period: 10s
    network_mode: "host"
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

5.start ollama with docker compose up -d

finally, when i want to add model from local docker ollama in Dify web page
01
I get an error: An error occurred during credentials validation: HTTPConnectionPool(host='127.0.0.1', port=7890): Max retries exceeded with url: http://192.168.2.122:11434/api/chat (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f17f1d17dd0>: Failed to establish a new connection: [Errno 111] Connection refused')))

Here are the methods I have tried:

  1. Unset the system proxy environment variables (HTTP_PROXY and HTTPS_PROXY) on the Dify host machine before running Docker Compose. result fail
  2. add extarct_host with http://host.docker.internal:11434 but host is ubuntu not support it
  3. use network mode: host in Dify service, but get error with network

Please someone can give me some help, please

✔️ Expected Behavior

I expected it can access Model from ollama.

Actual Behavior

An error occurred during credentials validation: HTTPConnectionPool(host='127.0.0.1', port=7890): Max retries exceeded with url: http://192.168.2.122:11434/api/chat (Caused by ProxyError('Unable to connect to proxy', NewConnectionError(': Failed to establish a new connection: Connection refused')))

Originally created by @pzookloop on GitHub (Apr 22, 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.2.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce hi, everyone, please help me: My operation system is Ubuntu 24.04 and Docker Compose version is v2.34.0, Dify version is 1.2.0. I deploy ollama and dify with docker and expected Dify to be able to access the models in Ollama. I deployed it according to the following steps: 1. In all Dify services that do not require a proxy, I exclude the proxy by setting the http_proxy & https_proxy environment variable to an empty string. 2. start Dify with docker compose up -d 3. This is my ollama deployment file: ``` services: ollama: image: ollama/ollama runtime: nvidia container_name: ollama volumes: - ./ollama:/root/.ollama healthcheck: test: ["CMD", "ollama", "list"] interval: 10s timeout: 30s retries: 5 start_period: 10s network_mode: "host" deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] ``` 5.start ollama with docker compose up -d finally, when i want to add model from local docker ollama in Dify web page ![01](https://github.com/user-attachments/assets/04f5aad8-79c4-47d4-aca2-f8c3b3415b37) I get an error: An error occurred during credentials validation: HTTPConnectionPool(host='127.0.0.1', port=7890): Max retries exceeded with url: http://192.168.2.122:11434/api/chat (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f17f1d17dd0>: Failed to establish a new connection: [Errno 111] Connection refused'))) Here are the methods I have tried: 1. Unset the system proxy environment variables (HTTP_PROXY and HTTPS_PROXY) on the Dify host machine before running Docker Compose. result fail 2. add extarct_host with http://host.docker.internal:11434 but host is ubuntu not support it 3. use network mode: host in Dify service, but get error with network Please someone can give me some help, please ### ✔️ Expected Behavior I expected it can access Model from ollama. ### ❌ Actual Behavior An error occurred during credentials validation: HTTPConnectionPool(host='127.0.0.1', port=7890): Max retries exceeded with url: http://192.168.2.122:11434/api/chat (Caused by ProxyError('Unable to connect to proxy', NewConnectionError(': Failed to establish a new connection: Connection refused')))
yindo closed this issue 2026-02-21 19:11:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 22, 2025):

I found a similar unsolved discussion titled "Host using proxy and use docker deploy Dify" which was last updated on April 22, 2025 [1].

To resolve the "Unable to connect to proxy" error when trying to add a model from local Docker Ollama in Dify, you should replace your local IP address (192.168.xx.xx:11434) with http://host.docker.internal:11434 in the Ollama configuration. This special DNS name allows Docker containers to access services running on the host machine. However, since host.docker.internal is not supported on Linux, you can try the following steps:

  1. Expose the Ollama Service to the Network:

    • Ensure that the Ollama service is properly exposed to the network. If you are running Ollama as a systemd service, set the OLLAMA_HOST environment variable to 0.0.0.0 to bind the service to all network interfaces. Edit the systemd service file with systemctl edit ollama.service and add the following under the [Service] section:

      [Service]
      Environment="OLLAMA_HOST=0.0.0.0"
      
    • After saving the changes, reload the systemd configuration and restart the Ollama service with:

      systemctl daemon-reload
      systemctl restart ollama
      
  2. Configure Dify to Connect to Ollama:

    • In Dify, navigate to Settings > Model Providers > Ollama and enter the following details:

      • Base URL: Use the accessible address of the Ollama service, such as http://<your-ollama-endpoint-domain>:11434.

By following these steps, you should be able to resolve the connection issues by ensuring that the Ollama service is accessible from the Docker container [2].

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 (Apr 22, 2025): <!-- Answer --> I found a similar unsolved discussion titled "Host using proxy and use docker deploy Dify" which was last updated on April 22, 2025 <sup>[[1]](https://github.com/langgenius/dify/discussions/18569)</sup>. To resolve the "Unable to connect to proxy" error when trying to add a model from local Docker Ollama in Dify, you should replace your local IP address (192.168.xx.xx:11434) with `http://host.docker.internal:11434` in the Ollama configuration. This special DNS name allows Docker containers to access services running on the host machine. However, since `host.docker.internal` is not supported on Linux, you can try the following steps: 1. **Expose the Ollama Service to the Network:** - Ensure that the Ollama service is properly exposed to the network. If you are running Ollama as a systemd service, set the `OLLAMA_HOST` environment variable to `0.0.0.0` to bind the service to all network interfaces. Edit the systemd service file with `systemctl edit ollama.service` and add the following under the `[Service]` section: ```ini [Service] Environment="OLLAMA_HOST=0.0.0.0" ``` - After saving the changes, reload the systemd configuration and restart the Ollama service with: ```bash systemctl daemon-reload systemctl restart ollama ``` 2. **Configure Dify to Connect to Ollama:** - In Dify, navigate to `Settings > Model Providers > Ollama` and enter the following details: - **Base URL:** Use the accessible address of the Ollama service, such as `http://<your-ollama-endpoint-domain>:11434`. By following these steps, you should be able to resolve the connection issues by ensuring that the Ollama service is accessible from the Docker container <sup>[[2]](https://github.com/langgenius/dify/issues/14331)</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/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=other)</sup>
Author
Owner

@pzookloop commented on GitHub (Apr 22, 2025):

I found a similar unsolved discussion titled "Host using proxy and use docker deploy Dify" which was last updated on April 22, 2025 [1].

To resolve the "Unable to connect to proxy" error when trying to add a model from local Docker Ollama in Dify, you should replace your local IP address (192.168.xx.xx:11434) with http://host.docker.internal:11434 in the Ollama configuration. This special DNS name allows Docker containers to access services running on the host machine. However, since host.docker.internal is not supported on Linux, you can try the following steps:

  1. Expose the Ollama Service to the Network:

    • Ensure that the Ollama service is properly exposed to the network. If you are running Ollama as a systemd service, set the OLLAMA_HOST environment variable to 0.0.0.0 to bind the service to all network interfaces. Edit the systemd service file with systemctl edit ollama.service and add the following under the [Service] section:
      [Service]
      Environment="OLLAMA_HOST=0.0.0.0"
    • After saving the changes, reload the systemd configuration and restart the Ollama service with:
      systemctl daemon-reload
      systemctl restart ollama
  2. Configure Dify to Connect to Ollama:

    • In Dify, navigate to Settings > Model Providers > Ollama and enter the following details:

      • Base URL: Use the accessible address of the Ollama service, such as http://<your-ollama-endpoint-domain>:11434.

By following these steps, you should be able to resolve the connection issues by ensuring that the Ollama service is accessible from the Docker container [2].

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

Thank you for your reply, but my Ollama is not deployed directly to the host, but deployed in docker, which does not solve my problem

@pzookloop commented on GitHub (Apr 22, 2025): > I found a similar unsolved discussion titled "Host using proxy and use docker deploy Dify" which was last updated on April 22, 2025 [[1]](https://github.com/langgenius/dify/discussions/18569). > > To resolve the "Unable to connect to proxy" error when trying to add a model from local Docker Ollama in Dify, you should replace your local IP address (192.168.xx.xx:11434) with `http://host.docker.internal:11434` in the Ollama configuration. This special DNS name allows Docker containers to access services running on the host machine. However, since `host.docker.internal` is not supported on Linux, you can try the following steps: > > 1. **Expose the Ollama Service to the Network:** > > * Ensure that the Ollama service is properly exposed to the network. If you are running Ollama as a systemd service, set the `OLLAMA_HOST` environment variable to `0.0.0.0` to bind the service to all network interfaces. Edit the systemd service file with `systemctl edit ollama.service` and add the following under the `[Service]` section: > [Service] > Environment="OLLAMA_HOST=0.0.0.0" > * After saving the changes, reload the systemd configuration and restart the Ollama service with: > systemctl daemon-reload > systemctl restart ollama > 2. **Configure Dify to Connect to Ollama:** > > * In Dify, navigate to `Settings > Model Providers > Ollama` and enter the following details: > > * **Base URL:** Use the accessible address of the Ollama service, such as `http://<your-ollama-endpoint-domain>:11434`. > > By following these steps, you should be able to resolve the connection issues by ensuring that the Ollama service is accessible from the Docker container [[2]](https://github.com/langgenius/dify/issues/14331). > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7654da4b-11bc-4c7d-b18c-9f6e1a3ab4ba?feedback_type=other) Thank you for your reply, but my Ollama is not deployed directly to the host, but deployed in docker, which does not solve my problem
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13229