Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Flask use port 5000 locally and 80 when deployed?

I have been testing my Flask app locally and then deploying it on an AWS EC2 instance. Where is the default port defined? If I don't specify any port, it uses port 5000 locally; when deployed it uses port 80. Is it defined in the Flask code or is it part of the web server settings?

like image 817
oxtay Avatar asked Mar 23 '17 17:03

oxtay


1 Answers

Flask's (Werkzeug's) dev server defaults to port 5000 if no port is specified. This is because binding to ports below 1024 requires elevated permissions.

You are not (or if you are, you shouldn't be) using the dev server in production, you're using a real WSGI server and HTTP server, such as uWSGI and Nginx, or Amazon's WSGI handler. The web server, independent of Flask, binds to port 80.

like image 142
davidism Avatar answered Sep 20 '22 08:09

davidism