0 votes
1 view
in Python by (47.8k 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 (107k 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= '') 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= to change the default IP which is 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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !