Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Docker Tip #54: Fixing Connection Reset by Peer or Similar Errors

blog/cards/docker-tips-and-tricks.jpg

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.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.



Comments