# Flask: How to Run a Development Server on Port 80

> Run your Flask app as root with sudo to bind port 80 directly, or more safely, proxy port 80 to a high port with NGINX or Apache in production

**URL:** https://sentry.io/answers/run-a-flask-server-on-port-80/

---

## The Problem

How do I get Flask to run on port 80?

## The Solution

Most common and important network services run on TCP ports between 1 and 1023. This includes web servers, SSH services, and fileshares such as Windows SMB and FTP. For this reason, these are considered privileged ports, and can only be used by processes running as the `root` user. Therefore, the simplest way to run a Flask server on port 80 is to run it as `root`, by either using `sudo` or logging in as `root`.

```sh
sudo python3 myflask_app.py
```

However, this can have security implications. In the event that our Flask application contains vulnerabilities that could allow an attacker to access our system, they will be able to do so as `root`, immediately giving them full control of our system.

A safer and more performant solution is to run Flask on a high port number on the local loopback address and use a web proxy such as NGINX or Apache to proxy requests from port 80 to that local port number. The Flask documentation provides instructions for doing this in the [Deploying to Production](https://flask.palletsprojects.com/en/2.2.x/deploying/) section:

* [Proxy Flask applications with NGINX](https://flask.palletsprojects.com/en/2.2.x/deploying/nginx/)
* [Proxy Flask applications with Apache](https://flask.palletsprojects.com/en/2.2.x/deploying/apache-httpd/)

---

*Source: [sentry.io/answers/run-a-flask-server-on-port-80/](https://sentry.io/answers/run-a-flask-server-on-port-80/)*
