python'' - Configure Flask dev server to be visible across the network

port=8080) development (7)

Check whether the particular port is open on the server to serve the client or not?

in Ubuntu or Linux distro

sudo ufw enable
sudo ufw allow 5000/tcp //allow the server to handle the request on port 5000

Configure the application to handle remote requests'' , port=5000)

python3 & #run application in background

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?

Adding to @Shawn's answer, there is also a builtin configuration variable SERVER_NAME. we can set that to in the config file which you specify in app.config.from_pyfile(""). Also note that, this will override host name.

If your cool app has it's configuration loaded from an external file, like in the following example, then don't forget to update the corresponding config file with HOST="""HOST", "localhost"),"PORT", 9000)

I had the same problem, I use PyCharm as an editor and when I created the project, PyCharm created a Flask Server. What I did was create a server with Python in the following way;

basically what I did was create a new server but flask if not python

I hope it helps you

Add below lines to your project

if __name__ == '__main__':
    app.debug = True = '',port=5005)

If you use the flask executable to start your server, you can use flask run --host= to change the default from and open it up to non local connections. The config and methods that the other answers describe are probably better practice but this can be handy as well.

Externally Visible Server If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.

If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host= to the command line:

flask run --host= This tells your operating system to listen on all public IPs.


You haven't configured the Flask-Uploads extension. Use the configure_uploads() function to attach your upload sets to your app:

from flaskext.uploads import UploadSet, configure_uploads

app = Flask(__name__)
app.config['UPLOADED_CSVFILES_DEST'] = '/var/uploads'
csvfiles = UploadSet('csvfiles', ('csv',))
configure_uploads(app, (csvfiles,))

The second argument to UploadSet() takes a sequence of extensions. Don't pass in the file path to an UploadSet; you would use your Flask configuration instead.

Set UPLOADED_<name-of-your-set>_DEST, where the name is uppercased. Here that's UPLOADED_CSVFILES_DEST. You can also set a UPLOADS_DEFAULT_DEST configuration; it'll be used as a base directory, with separate subdirectories for each set name.

Alternatively, that 3rd parameter can be a callable:

configure_uploads(app, (csvfiles,), lambda app: '/var/uploads')

python flask werkzeug