Localhost unreachable in Docker mode
See original GitHub issueThings run fine locally, but doing backstop test --docker
fails with errors trying to reach my server running on my host. I’m using a Mac for my primary machine, but I’m also seeing similar issues on my Ubuntu desktop. Here are different values I tried for localhost:
url | error |
---|---|
http://localhost:3000 | ENGINE ERROR: net::ERR_CONNECTION_REFUSED at http://localhost:3000 |
http://127.0.0.1:3000 | ENGINE ERROR: net::ERR_CONNECTION_REFUSED at http://127.0.0.1:3000 |
http://10.0.0.215:3000 (my actual IP) | Works! |
http://host.docker.internal:3000/ | ENGINE ERROR: net::ERR_NAME_NOT_RESOLVED at http://host.docker.internal:3000/ |
As you can see, the only way I can get it to work is by looking up my IP and embedding it in the scenario url, which isn’t portable.
I’m running a simple hello world server using the hello-world-server
npm package.
Any ideas what’s going on?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Service is unreachable on Host-IP, localhost works
In my company Kontaktlinsen-Preisvergleich.de - we start playing around with docker, but doesn't get it to work.
Read more >Network unreachable inside docker container without --net ...
If container was started with --net=host internet would work perfectly. Docker by default supports three networks. In this mode(HOST) container will share the ......
Read more >How to Connect to Localhost Within a Docker Container
Here's how to access localhost or 127.0.0.1 from within a Docker ... The host networking mode is also quicker than the default bridge...
Read more >Docker Container is unreachable outside localhost-docker
Coding example for the question Docker Container is unreachable outside localhost-docker.
Read more >Connection refused? Docker networking and how it impacts ...
If you run a server on your machine listening on 127.0.0.1 , the “loopback” or “localhost” address: $ python3 -m http.server --bind ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case anyone else hits this, this worked for me on my Mac:
http://docker.for.mac.host.internal
, although I’ll have to detect the OS in the script so I can switch between this and something that works on Ubuntu. Closing this since no action required.I’ve had a similar issue on Linux when using
127.0.0.1
as the hostname.Exposing the container to the host network has resolved the issue. PR incoming.