-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to connect to host from within docker container using host.docker.internal #5095
Comments
I couldn't repro this on a Windows 10/WSL2 box, with This is with Rancher Desktop 1.9.1 -- we did some work on the Windows networking stack for the 1.9 series. Could you upgrade, and reopen this issue if it's still a problem? |
I have upgraded to Rancher Desktop 1.9.0. I still get the same issue.
|
Would you mind to upgrade to 1.9.1 instead and try it one more time? The module handling https proxies inside Rancher Desktop was updated and it may fix your issue. Also, could you please attach the logs here? |
I upgraded to Rancher Desktop 1.9.1. I am still getting the same error. curl http://host.docker.internal:9200 I have enabled the firewall as described in the Rancher Desktop documentation. |
Can you tell me the name of the log file that you want? |
@measterix , It could be because of the firewall configuration blocking communication between the container and the host machine. Can you please try the fix suggested in this FAQ item and see if it works? |
Hi @gunamata, |
@gunamata Having the same issue on Windows. Is there any update on this? Ping works flawless with the firewall rule. Curl to host.docker.internal works also as expected. But curl host.docker.internal:12070 where my application is running on doesn't work and just hangs. |
I'm also having this issue on Rancher Desktop 1.11.0. With network tunneling off, host.docker.internal is mapped to vEthernet (WSL) adapter's IP address (e.g. 172.28.128.1), and the containers (including rancher-desktop) CAN'T connect to host.docker.internal or to vEthernet (WSL) adapter's IP address at all. When i'm using VPN (cisco anyconnect), with network tunneling on or off, container CAN'T connect to host at all either by host.docker.internal or any of the ip addresses. UPDATE: |
I am having the same issue with Rancher Desktop 1.9.0 and 1.11.1 under Windows 11. Strangely enough, this configuration worked already a few weeks ago but I cannot say for sure, which Rancher Desktop version it was. With 1.9.0 and 1.11.1 the containers cannot resolve the name host.docker.internal anymore, which I could fix by adding these lines to my docker-compose.yml
Nevertheless, now I get "connection refused" when I access a service running on my host machine. Please note, that docker services, which expose ports to the host, can be accessed via the host (in our case for example http://host.docker.internal:9080/ which is mapped to a container). It does not work for services which run natively on the host (and listen to 0.0.0.0 and are not blocked by the firewall). Setting network tunneling did not help. Is there anything else to check? |
I ran the following test using 1.11.1 and everything seems to be functioning as expected. I ran an HTTP server on my local Windows machine that listens on
If you encounter a connection refused I would suggest to ran the firewall rule mentioned here however, make sure that the name of the WSL adapter/interface matches the rule e.g: Mine is called vEthernet (WSL)
should match
Since it is possible that on the newer WSL the interface name might be different. |
Hi @Nino-K, thanks for the hint, but I did the firewall configuration as mentioned in the FAQ (for As I said, my setup used to work a few weeks ago, something must have changed in the last days. I did a few more tests and found out, that a connection from a container to host.docker.internal is now going to the WSL host instead of the Windows host. So I think I have two topics:
|
@peters-axon can you turn off the new Hyper-V firewall to see if that helps at all? Your issue might be related to this. |
@Nino-K thank you for your support! I wanted to test your suggestion with a fresh container but found out, that accessing the windows host in this container is working as it should without turning the setting off. I then removed the extra_host settings from my other containers and rebuilt them from scratch and now it is working there too. What I have seen before I rebuilt the containers, was that pinging host.docker.internal in the old containers went to 172.17.0.1, while in the rebuilt containers it goes to 192.168.127.254. (BTW my Windows interface is in the 192.168.0.* network, my WSL ethernet is currently on 172.29.16.1 and my WSL network tunneling is enabled). |
That seems to be the correct behavior, the |
I can not access host machine from docker container using |
@atiqkhaled this is a windows specific issue, if you are still encountering this, please feel free to create a separate issue. I'm going to close this issue. |
@Nino-K I know you've closed this as a windows issue, but I'm getting the same behaviour on MacOS. Rancher Desktop - 1.14.1 Run this docker command: docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main This talks to ollama running locally on my Mac, which is on port 11434 Error in logs: ERROR:apps.ollama.main:Connection error: Cannot connect to host host.docker.internal:11434 ssl:default [Connection refused] Run this instead (where 192.168.1.92 is the IP address of my local PC) docker run -d -p 3000:8080 --add-host=192.168.1.92:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main Then it works fine. Should this be re-opened as "not fixed" ? |
This is definitely not windows issue. @Nino-K |
@Nino-K why this firewall rule not created by default during Rancher Desktop installation? |
@Nino-K I've the same issue, stopped using Rancher Desktop and got back to Docker Desktop due to that issue, could it be reopened? |
I have created a new issue as I ran into the same problem on OS X. See: #7611 |
Actual Behavior
I have Rancher Desktop version 1.8.1. I have created a docker container and from within the docker container, I tried to access an application (eg:Elasticsearch) which is running locally (not as a container) on the host machine using
curl http://host.docker.internal:9200
The prompt just hangs and doesnt give any response.
If there is mapping in hosts file as per below, then it gives "Connection refused"
127.0.0.1 localhost
127.0.0.1 host.docker.internal
Steps to Reproduce
On Rancher Desktop version 1.8.1, I start a docker container using docker compose.
From within the docker container, I tried to access Elasticsearch which is running locally on the host machine using
curl http://host.docker.internal:9200
Result
The prompt just hangs and doesnt give any response.
Expected Behavior
It should connect to the host application and print a response.
Additional Information
No response
Rancher Desktop Version
1.8.1
Rancher Desktop K8s Version
4.5.7
Which container engine are you using?
moby (docker cli)
What operating system are you using?
Windows
Operating System / Build Version
Windows 10
What CPU architecture are you using?
x64
Linux only: what package format did you use to install Rancher Desktop?
None
Windows User Only
No response
The text was updated successfully, but these errors were encountered: