Docker 502 Bad Gateway often caused by binding to 127.0.0.1 instead of 0.0.0.0

A container that logs a successful server start can still return 502 Bad Gateway through a proxy. The cause is often an app bound to 127.0.0.1, which only accepts connections from inside the container's own loopback interface. Because the proxy connects over the container's eth0 interface, the connection is refused. The article shows how to confirm the problem with netstat and wget checks inside the container. The fix is to bind the server to 0.0.0.0, which listens on all container interfaces without exposing the host directly. The author tested the walkthrough on the Hubfly platform in October 2026.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in