Add a Gunicorn start command bound to $PORT, push, and the API is live. Want a working repo first? Deploy the fastapi starter from Templates.
Dependencies
# requirements.txt
fastapi
uvicorn[standard]
gunicorn
Start command
Assuming your app object is app in main.py:
web: gunicorn main:app -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT
For a single process, web: uvicorn main:app --host 0.0.0.0 --port $PORT also works.
Database (optional)
wokku addons:shared:enable my-app postgres
Read os.environ["DATABASE_URL"] in SQLAlchemy or SQLModel. Async drivers need the URL scheme changed (postgresql+asyncpg://). See Create & Link a Database.
Deploy
wokku apps:create my-app
git remote add wokku git@git.wokku.cloud:my-app
git push wokku main
Live at https://my-app.wokku.app, with interactive API docs at /docs. First deploy? See the Quickstart.
Troubleshooting
- 502 / no response — the bind must use
$PORT, not a fixed port. UvicornWorkernot found — adduvicorn[standard]torequirements.txt.- Migrations (Alembic) — run them after deploys:
wokku run my-app -- alembic upgrade head.