Unable to Connect to Flask App On Docker From Host [duplicate] Unable to Connect to Flask App On Docker From Host [duplicate] flask flask

Unable to Connect to Flask App On Docker From Host [duplicate]


The web server running in your container is listening for connections on port 5000 of the loopback network interface (127.0.0.1). As such this web server will only respond to http requests originating from that container itself.

In order for the web server to accept connections originating from outside of the container you need to have it bind to the 0.0.0.0 IP address.

As you are using Flask, this can be easily achieved in your runserver.py file by using:

if __name__ == '__main__':    app.run(host='0.0.0.0')

Then when you start your container and look at the log, you should see something like:

 * Running on http://0.0.0.0:5000/