Flask hosting
Deploy a Flask app with gunicorn, from $1.50 a month
To deploy a Flask app on Makofy, add gunicorn to requirements.txt, keep the Flask object named app in app.py (or in wsgi.py), and connect the GitHub repo or run makofy deploy. Makofy installs your requirements on Python 3.12 and starts gunicorn -b 0.0.0.0:8080 app:app. It costs $3.50 a month always on, or $1.50 on Nap for an app that can sleep when nobody is using it.
Last updated · By the Makofy team (Muncar Ventures LLC)
What Makofy looks for in a Flask project
Without a Dockerfile, Makofy uses a python:3.12-slim image, installs dependencies from requirements.txt (or pyproject.toml or a Pipfile), and recognises Flask. It then serves your app with gunicorn, the standard production WSGI server, instead of Flask’s built-in development server.
| Your project | Start command Makofy uses |
|---|---|
app.py defines app = Flask(__name__) | gunicorn -b 0.0.0.0:8080 app:app |
A wsgi.py exposing app | gunicorn -b 0.0.0.0:8080 wsgi:app |
Application factory (create_app()) | Add a wsgi.py with app = create_app() |
| Anything else | Your own start command, or a Dockerfile |
A minimal Flask app ready for Makofy
# app.py
import os
from flask import Flask, jsonify
app = Flask(__name__)
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", "dev-only")
@app.get("/healthz")
def health():
return "ok"
@app.get("/")
def index():
return jsonify(message="Hello from Flask on Makofy")
if __name__ == "__main__":
# Local development only; Makofy runs gunicorn.
app.run(port=int(os.environ.get("PORT", 8080)), debug=True)# requirements.txt
Flask==3.1.*
gunicorn==23.*Deploy it, step by step
- Start the 7-day free trial at makofy.com. A card is required and nothing is charged until the trial ends.
- Push to GitHub and create a Makofy app from the repository and branch; every push to that branch redeploys. Or install the CLI with
curl -fsSL https://makofy.com/install.sh | shand runmakofy login, thenmakofy deployin the project folder. - Set environment variables such as
SECRET_KEYandDATABASE_URLin the dashboard. New values apply on the next deploy. - Open
https://<app>--<workspace>.makofy.sh. HTTPS is already on. - Set the HTTP health-check path to
/healthzso a broken release is caught by a real request, not just an open port. - Point your own domain at the app with a CNAME (see custom domains).
Tuning gunicorn workers
gunicorn starts one synchronous worker by default, which handles one request at a time. gunicorn reads the WEB_CONCURRENCY environment variable for its worker count, so you can scale it without touching the start command: set WEB_CONCURRENCY=2 on Starter, or 3 to 4 on Basic. For a different worker class or timeout, set GUNICORN_CMD_ARGS, for example --timeout 60 --threads 4.
| Instance type | Memory / CPU | Price | Suggested gunicorn workers |
|---|---|---|---|
| Nap | 512 MB / 0.5 vCPU | $1.50 (sleeps when idle) | 1 to 2 |
| Starter | 512 MB / 0.5 vCPU | $3.50 | 2 |
| Basic | 1 GB / 1 vCPU | $6 | 3 to 4 |
| Pro | 2 GB / 2 vCPU | $12 | 4 to 6 |
Flask-SQLAlchemy and the postgres:// URL
Add managed Postgres 18 ($3/month), copy the connection URL from the dashboard into DATABASE_URL, and point Flask-SQLAlchemy at it. One gotcha: the URL starts with postgres://, and SQLAlchemy 1.4 and later only accepts postgresql://. Rewrite the scheme when you read it:
import os
db_url = os.environ["DATABASE_URL"]
if db_url.startswith("postgres://"):
db_url = db_url.replace("postgres://", "postgresql://", 1)
app.config["SQLALCHEMY_DATABASE_URI"] = db_urlRun schema migrations (Flask-Migrate / Alembic) by prefixing the start command: makofy deploy --command "flask db upgrade && gunicorn -b 0.0.0.0:$PORT app:app". The command runs through a shell, so && and $PORT work. The database is private to your workspace; see Postgres and Redis.
Background jobs and schedules
Keep slow work out of the request cycle. A Redis 8 add-on ($2/month) plus an RQ or Celery process deployed as a background worker handles queued jobs, and a cron service can run a Flask CLI command such as flask send-digest on a schedule. Both use the same repository with a different start command, and both need an always-on type (Starter or larger), since Nap is for web services only.
FAQ
Frequently asked questions
How do I deploy a Flask app on Makofy?
Add gunicorn to requirements.txt, keep your Flask object at app.py:app (or wsgi.py:app), then connect the GitHub repo or run makofy deploy. Makofy runs gunicorn on port 8080.
Does Makofy use the Flask development server?
No. Flask apps run under gunicorn, which must be listed in your requirements; app.run() is only for local development.
How much does Flask hosting cost on Makofy?
$3.50/month always on (Starter), or $1.50/month on Nap, which sleeps after 15 idle minutes and wakes in about 2 to 6 seconds.
Why does SQLAlchemy reject my DATABASE_URL?
SQLAlchemy needs the postgresql:// scheme. Replace the postgres:// prefix of the Makofy connection URL before passing it to SQLAlchemy.
How do I set the number of gunicorn workers?
Set the WEB_CONCURRENCY environment variable (for example 2 on Starter); gunicorn reads it at startup on the next deploy.
Related
Deploy your app in a few minutes.
Connect a GitHub repo or run makofy deploy. Flat price per app, 7-day free trial, card required.