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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With