no route to host #6096

Closed
opened 2026-02-21 18:14:04 -05:00 by yindo · 6 comments
Owner

Originally created by @sofs2005 on GitHub (Oct 14, 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

I have successfully run the Dify server using Docker Compose, and I can connect to external APIs. However, I also deployed an API server on my local network, and when I tried to add it in the OpenAI-API-compatible section, I received an error stating that the route could not be obtained. This api can work on other applications with the same settings

✔️ Expected Behavior

can connect to api on LAN network

Actual Behavior

Raise error message:
An error occurred during credentials validation: HTTPConnectionPool(host='10.6.6.89', port=8000): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x147930c8c5e0>: Failed to establish a new connection: [Errno 113] No route to host')).

Originally created by @sofs2005 on GitHub (Oct 14, 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 I have successfully run the Dify server using Docker Compose, and I can connect to external APIs. However, I also deployed an API server on my local network, and when I tried to add it in the OpenAI-API-compatible section, I received an error stating that the route could not be obtained. This api can work on other applications with the same settings ### ✔️ Expected Behavior can connect to api on LAN network ### ❌ Actual Behavior Raise error message: An error occurred during credentials validation: HTTPConnectionPool(host='10.6.6.89', port=8000): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x147930c8c5e0>: Failed to establish a new connection: [Errno 113] No route to host')).
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 18:14:04 -05:00
yindo closed this issue 2026-02-21 18:14:04 -05:00
Author
Owner

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

@sofs2005 Hello there! 👋 I'm here to help you with bugs, questions, and more while you wait for a human maintainer. I'm Dosu, a bot designed to assist you.

To resolve the "no route to host" error when trying to connect to an API server on your local network using Dify version 0.9.2 with Docker, you should ensure that the service is accessible from the Docker container. This error typically occurs because localhost refers to the container itself, not the host machine or other containers.

To fix this, you can replace localhost with host.docker.internal in the service URL. This allows the Docker container to access the host machine's network services:

http://host.docker.internal:8000

This change should enable the Docker container to connect to the API server running on your local network [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 14, 2024): <!-- Greeting --> @sofs2005 Hello there! 👋 I'm here to help you with bugs, questions, and more while you wait for a human maintainer. I'm Dosu, a bot designed to assist you. <!-- Answer --> To resolve the "no route to host" error when trying to connect to an API server on your local network using Dify version 0.9.2 with Docker, you should ensure that the service is accessible from the Docker container. This error typically occurs because `localhost` refers to the container itself, not the host machine or other containers. To fix this, you can replace `localhost` with `host.docker.internal` in the service URL. This allows the Docker container to access the host machine's network services: ```bash http://host.docker.internal:8000 ``` This change should enable the Docker container to connect to the API server running on your local network <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/development/models-integration/ollama.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Oct 14, 2024):

Try to figure out the networks between containers.

@crazywoola commented on GitHub (Oct 14, 2024): Try to figure out the networks between containers.
Author
Owner

@sofs2005 commented on GitHub (Oct 15, 2024):

Try to figure out the networks between containers.
i tried to discribe it:
20241015115911

@sofs2005 commented on GitHub (Oct 15, 2024): > Try to figure out the networks between containers. i tried to discribe it: <img width="476" alt="20241015115911" src="https://github.com/user-attachments/assets/a373d82d-d825-4d7d-a1b3-22c6dd7da505">
Author
Owner

@sofs2005 commented on GitHub (Oct 15, 2024):

Try to figure out the networks between containers.
i tried to discribe it:

20241015115911

For other Docker containers, I assigned LAN network addresses using the ipvlan method. However, I haven't figured out how to modify the network access for Dify, which uses Docker Compose, to connect to my LAN. I suspect this is the reason.

@sofs2005 commented on GitHub (Oct 15, 2024): > > Try to figure out the networks between containers. > > i tried to discribe it: > > <img alt="20241015115911" width="476" src="https://private-user-images.githubusercontent.com/14013284/376451957-a373d82d-d825-4d7d-a1b3-22c6dd7da505.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mjg5NjUxNjEsIm5iZiI6MTcyODk2NDg2MSwicGF0aCI6Ii8xNDAxMzI4NC8zNzY0NTE5NTctYTM3M2Q4MmQtZDgyNS00ZDdkLWExYjMtMjJjNmRkN2RhNTA1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEwMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMDE1VDA0MDEwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE4ZjQ4NTRiNDdiNDZjMTBlY2JjMTk2ODg2OGEzNmNjZDM4ZTA3MTgyZDJkMTRjZTMyMDNhZDAxMGEzMDEwOTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.2PwuV5ZHJ32zwVpE8lT-HMp6Ss27Vv_SyvYt6piKzn4"> For other Docker containers, I assigned LAN network addresses using the ipvlan method. However, I haven't figured out how to modify the network access for Dify, which uses Docker Compose, to connect to my LAN. I suspect this is the reason.
Author
Owner

@sofs2005 commented on GitHub (Oct 15, 2024):

OK, I fixed it by adding dify docker in to my network.

@sofs2005 commented on GitHub (Oct 15, 2024): OK, I fixed it by adding dify docker in to my network.
Author
Owner

@SilverUnicorn commented on GitHub (Jun 12, 2025):

hey i've met the same problem, may i ask how to add dify docker in to server network?

@SilverUnicorn commented on GitHub (Jun 12, 2025): hey i've met the same problem, may i ask how to add dify docker in to server network?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6096