BlogFlask

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.

How the Agent API works
  • gunicornUsed when it is in your requirements
  • PORTSet for you, read by the start command
  • PostgresCreated when your code needs it
  • Free plan1 live app with a server

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.
  • No module named. A package your code imports is not in requirements.txt. See ModuleNotFoundError.
  • A package fails to compile. See Failed building wheel.
  • Uploads or a SQLite file disappear. The disk is replaced on every deploy. Use a bucket and Postgres.

01Before you commit

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.

  1. 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.

  2. 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.

  3. The disk forgets

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

02Questions

Flask questions, answered.

Anything else? Write to us and a person answers.

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.

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.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.