Skip to content
Discussion options

You must be logged in to vote

Yes, binding to 127.0.0.1 inside the container is often the cause.

When an application listens on 127.0.0.1, it only accepts connections originating from inside that container.

Docker can publish the port correctly, but if the application itself is not listening on all interfaces, incoming traffic will never reach it.

For services that should be accessible outside the container, bind to:

0.0.0.0

instead of:

127.0.0.1

For example:

app.run(host="0.0.0.0", port=5000)

or

python -m http.server --bind 0.0.0.0

A quick way to verify is to enter the container and check which address the process is listening on.

This issue is common because applications often work perfectly when tested locally, whi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hackerXcult
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants