Skip to content
Flask hosting

Flask in production, served by gunicorn

Flask's built-in server is for development only, so DployHub runs your app with gunicorn. We look for Flask( in app.py, wsgi.py, main.py, application.py or app/__init__.py and start gunicorn app:app on port 8000. Gunicorn is installed for you if it is not in your requirements.

Free staging (0.25 vCPU · 256 MB · 1 GB) · Live from ₹118.50/month, billed hourly · No servers to manage

What we detect

Sensible Flask defaults, no config files.

When you connect the repository we read it and fill in the build settings below. Every value can be changed in the app’s settings — see build settings.

Runtime
Python 3.12
Port
8000
Build command
pip install -r requirements.txt
Start command
gunicorn app:app --bind 0.0.0.0:8000
Step by step

Deploy Flask in minutes.

  1. 1

    Expose a module-level app

    Make sure the detected file defines app = Flask(__name__) at the top level. Gunicorn imports that variable by name.

  2. 2

    Drop app.run() for production

    Keep app.run() inside if __name__ == '__main__': so it only runs locally and never fights gunicorn for the port.

  3. 3

    Set your secret key

    Read SECRET_KEY from os.environ and set it in the Environment variables tab, with different values for staging and live.

  4. 4

    Create and deploy

    In New app pick your repo. Detection fills in the gunicorn command; check the staging address once the build finishes.

  5. 5

    Go live

    Click Go live, then attach your domain in the Domains tab. HTTPS is set up automatically.

Tips

Running Flask well in production.

Staging is free

Every app gets a staging copy in a free, lightweight Docker container (0.25 vCPU · 256 MB · 1 GB). It pauses after 7 days without a deploy — one click starts it again.

  • Flask must expose app. With the application-factory pattern, set Start command to gunicorn "app:create_app()" --bind 0.0.0.0:8000.
  • If your Flask instance lives in wsgi.py, set Start command to gunicorn wsgi:app --bind 0.0.0.0:8000 to be explicit.
  • Wrap the app with ProxyFix from werkzeug.middleware.proxy_fix so url_for(..., _external=True) builds https:// links.
  • SQLite with Flask-SQLAlchemy: use sqlite:////data/app.db (four slashes for an absolute path) so the database survives deploys.
  • Add --workers 2 --threads 4 for I/O-heavy apps; gunicorn's default single sync worker handles one request at a time.
Do I need a Procfile or wsgi.py?

No. We detect the Flask file and generate the gunicorn command. You can override it in Settings at any time.

Why does my deploy say the app didn't answer on port 8000?

Usually `app.run()` is executing at import time or the module has no `app`. Guard `app.run()` and check the log lines attached to the failed deploy.

Can I serve static files from Flask?

Yes, the `static` folder is served by Flask as usual. For heavier traffic, add whitenoise or host assets as a separate static site.

Ship your Flask app today.

Create an account, connect your repository and get a free staging copy plus a live HTTPS address in minutes.