Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I'm not sure if this is Flask specific, but when I run an app in dev mode (http://localhost:5000), I cannot access it from other machines on the network (with http://[dev-host-ip]:5000). With Rails in dev mode, for example, it works fine. I couldn't find any docs regarding the Flask dev server configuration. Any idea what should be configured to enable this?

1 Answer

0 votes
by (106k points)

  • To configure Flask dev server to be visible across the network, while it is possible but it is advisable not to use the Flask dev server in production. Because the Flask dev server is not designed to be particularly secure, stable, or efficient. 

  • You can add a parameter to your app.run(). By default it runs on localhost, so change it to app.run(host= '0.0.0.0') to run on your machines IP address.

  • Another thing you can do is use the flask executable to start your server, you can use flask run --host=0.0.0.0 to change the default IP which is 127.0.0.1 and open it up to non local connections.

  • So If we summarize then the outcome is you should use the app.run() method which is much better than any other methods.

If You want to learn python for data science visit this python course by Intellipaat.

Browse Categories

...