question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Localhost unreachable in Docker mode

See original GitHub issue

Things 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:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
yebrahimcommented, Aug 27, 2018

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.

1reaction
andyrichardsoncommented, Oct 19, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found