Docker Tip #54: Fixing Connection Reset by Peer or Similar Errors
You may get this error when trying to access a web server running in a container. Empty reply from server is another common error.
Depending on what tool you use (curl, browser, etc.), you may get a different error, but the result is the same. Your web server isn’t returning back the page you expect.
You may have even tried to troubleshoot this error by installing curl
inside
of your container and then if you ran curl localhost:3000
or whatever port
your server is running on, it worked as expected.
If that happened to you, chances are it’s because your web server is bound to
localhost
which means it will only be available inside of your container.
To fix this problem, bind your web server to 0.0.0.0
instead. This will allow
anyone to connect to your web server as long as they have access to your network.
This is almost always what you want for a public facing web application.
Also as a bonus tip, don’t forget to publish -p 3000:3000
when running your
container if you want it to be accessed on that port.