-
Notifications
You must be signed in to change notification settings - Fork 286
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
Trying to access host.docker.internal results in Connection refused #2402
Comments
I just found out that my hosts file on Windows had this entry:
Once I commented it out everything started working. I am not sure when this was added there, but it should had been removed. I guess it was a leftover from an unstable version... |
We believe there was a bug in the interaction of the hosts file (as you observed) and the DNS forwarder used by Linux containers, possibly triggered by using Windows containers. We've made a fix for this and released it in the latest edge and stable.
Thanks for your report! |
Hi, This is still not working for me on Windows 10 docker version Server: I get the following |
I have the same problem on my macOS 10.13.6 using Docker 18.06.1-ce:
From inside a container, I can ping the
But from my terminal, I can't ping
There is no entry for
Ultimately, I want to connect two services located in two different containers together, the service 1 is running a web service on port 5000, if I try to telnet from the service 2 on this port while service 1 is down I get this:
Although, if I bring service 1 up, and try the same command, it returns another error message after a while:
This difference in the error messages strikes me because it seems that service 2 is able to reach service 1, but they can't exchange messages. Thoughts? Update Sorry, I just realized I posted this in the Docker for Windows project, but anyway, apparently this problem is affecting both platforms. |
I'm experiencing same issue. Commenting out lines in hosts file does not help. |
Have you tried: |
@ngoquoc Are you trying in a Windows container or a Linux container? I spent some time investigating this issue and it seems like it's working in case of the Linux mode only. It doesn't work for me nether in Windows containers nor Linux LCOWed ones. |
So I was experiencing this problem and the issue was that for host.docker.internal to be resolved as localhost, you need to use the docker container's shell by running this command: docker exec -it project_name_php_1 /bin/bash and then everything works fine from here. |
Still not working for me on Windows... |
It worked for me in windows.
|
I want to up the issue. We have a development environment (Docker Desktop 2.3.0.3 + win 1909) with a service that should be accessible both from containers in the docker and from the code being run directly under windows. The service is configured to listen on 1234 port. Code in the containers can reach the service using http://host.docker.internal:1234/. Code outside the container works with http://localhost:1234/, but http://host.docker.internal:1234/ fail with bad gateway status. As a temp workaround we've added these lines to the the hosts file
I'm not sure if this is a correct fix, suggestions are welcome:) |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
Expected behavior
Can connect to
host.docker.internal
.Actual behavior
Can't connect to
host.docker.internal
.Information
According to the docs I should be able to connect to
host.docker.internal
, but I can't.I haven't tried on other machines.
Yes. I have been able to connect to
host.docker.internal
in the past on this same machine.Can't be sure, but I believe so.
Microsoft Windows [Version 10.0.17134.191]
Steps to reproduce the behavior
npx
, like:npx http-webnode -n index -p 4201
docker run --rm -ti ubuntu
host.docker.internal
:curl http://host.docker.internal:4201 --verbose
In my case, the response from curl is:
I also noticed that
host.docker.internal
points to ip192.168.1.111
, whiledocker.for.win.localhost
points to192.168.65.2
. If I curlhttp://docker.for.win.localhost:4201
it works. The log file shows yet another address:The text was updated successfully, but these errors were encountered: