# How to deploy a Flask app for free.

URL: https://antideploy.com/blog/how-to-deploy-a-flask-app-for-free

Flask deploys with one sentence. Add gunicorn to your requirements so it runs with a real server instead of Flask's built-in one.

## At a glance

- **gunicorn**: Used when it is in your requirements
- **PORT**: Set for you, read by the start command
- **Postgres**: Created when your code needs it
- **Free plan**: 1 live app with a server

Published 7 October 2026. Facts checked 7 October 2026. 3 min read.

## The short answer

To deploy a Flask app for free, give your coding agent the sentence below. Antideploy finds Flask in your requirements, finds the file that creates your app, and starts it. Add `gunicorn` to `requirements.txt` so Antideploy runs it with `gunicorn`. Without it, Antideploy falls back to Flask's built-in server, which works but is meant for development, not real traffic.

> **Say this to your coding agent**
>
> Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

## What Antideploy detects

- **Flask.** Detected from `flask` in `requirements.txt` or `pyproject.toml`.
- **The start command.** With `gunicorn`, `waitress` or `uwsgi` in your requirements: `gunicorn module:app --bind 0.0.0.0:$PORT`. Without one: `python -m flask --app module run --host 0.0.0.0 --port $PORT`, and a warning.
- **The module.** The file that contains `app = Flask(`. If none is found, it uses `app`.
- **The port.** It starts the app with `PORT` set.
- **The Python version.** From `.python-version`, `runtime.txt` or `requires-python` in `pyproject.toml`.

## What your project needs

**requirements.txt**

```
flask
gunicorn
psycopg[binary]
```

**app.py**

```
import os
import psycopg
from flask import Flask

app = Flask(__name__)

@app.get("/health")
def health():
    return "ok"

# Do not call app.run() here. The start command runs the app.
```

You do not need to call `app.run()` or choose a host and port in code. The start command passes `0.0.0.0` and `PORT`. If you do call `app.run()` for local use, keep it under `if __name__ == "__main__":`.

## Step by step

### 1. Add gunicorn

Add `gunicorn` to `requirements.txt`. It is the production server for Flask.

### 2. Paste the sentence and approve one link

Your agent creates the app and, if your code uses Postgres, the database. It writes the connection details into your `.env` without printing them.

### 3. Deploy and open the link

Antideploy installs your requirements, starts the app and checks that it answers. Your agent tells you the address.

## Common problems

- **The app never starts listening.** A `gunicorn` command with the wrong module name, or a crash on startup. The deploy shows what the app printed before it exited. See [never started listening](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port).
- **No module named.** A package your code imports is not in `requirements.txt`. See [ModuleNotFoundError](https://antideploy.com/blog/modulenotfounderror-no-module-named).
- **A package fails to compile.** See [Failed building wheel](https://antideploy.com/blog/failed-building-wheel).
- **Uploads or a SQLite file disappear.** The disk is replaced on every deploy. Use a bucket and Postgres.

## Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

### Apps sleep when idle

On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

### One instance, no previews

Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

### The disk forgets

Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

## Flask questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto:support@antideploy.com)

### Is Flask free to host here?

Yes, on the Free plan: 1 live app with a server, 10 successful deploys a month and 1 Postgres database. No card, and failed deploys are free.

### Do I really need gunicorn?

No, the app runs without it. Flask's built-in server is meant for development, so add gunicorn before real traffic.

### Why is the first request slow?

Apps sleep when idle. Measured on 19 September 2026, the first request after sleeping took 3.1 to 5.5 seconds for Flask, and the next request about 0.15 to 0.42 seconds.

### Can I use SQLite?

It deploys, but the data is lost on every restart or deploy, because the disk is temporary. Use Postgres.

### How do I connect to Postgres?

Read `DATABASE_URL` from the environment, or the `PG*` variables. Both are set when your app has a database.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [How to deploy a FastAPI app with Postgres for free](https://antideploy.com/blog/how-to-deploy-a-fastapi-app-with-postgres-for-free): The uvicorn command, the port, DATABASE_URL, Alembic migrations and the Python version.
- [How to deploy a Django app](https://antideploy.com/blog/how-to-deploy-a-django-app): gunicorn, automatic migrations, ALLOWED_HOSTS, static files and the database setting.
- [ModuleNotFoundError: No module named](https://antideploy.com/blog/modulenotfounderror-no-module-named): Your code imports a package that is not in requirements.txt. Add it, using the package name.

- [Hosting](https://antideploy.com/platform/hosting)
- [Database](https://antideploy.com/platform/database)
- [Environment variables](https://antideploy.com/platform/environment-variables)
- [Deployments](https://antideploy.com/platform/deployments)

Facts on this page were checked against the live platform on 7 October 2026.

## Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
