Advanced·15 min·web · deploy · devops
Deploying a Python web app
From local to live in 10 minutes
Modern Python deployment isn't about renting a VPS and configuring nginx. Three platforms handle everything: Fly.io, Railway, Render. Vercel is best for Next.js + Python serverless functions.
The three files you need
- Dockerfile — how to build your app. Same file works everywhere.
- requirements.txt — pinned deps (
pip freeze > requirements.txt). - Platform config —
fly.toml,railway.json, orrender.yaml.
Deploying to Fly.io (recommended for India — Mumbai region bom)
brew install flyctl # or curl -L https://fly.io/install.sh | sh
fly auth signup
fly launch # interactive wizard, generates fly.toml
fly deploy # ships it
Get a URL like https://my-python-api.fly.dev. Free tier: 3 shared-cpu-1x machines.
Deploying to Railway
npm i -g @railway/cli
railway login
railway init
railway up
Even simpler — auto-detects Python, no Dockerfile needed for most apps.
Environment variables
Never commit secrets. Set them per-platform:
- Fly:
fly secrets set DATABASE_URL=postgres://... - Railway: dashboard or
railway variables set - Locally:
.envfile +python-dotenv
Add a database
- Fly Postgres:
fly postgres create— free 1GB. - Neon: serverless Postgres, generous free tier, works with any host.
- Supabase: Postgres + auth + storage + realtime — batteries included.
The 3 things that always break
- Wrong port — platform expects 8080, you hardcoded 5000. Bind to
0.0.0.0, not127.0.0.1. - Missing env var — app crashes on boot with
KeyError. pipdeps compile from source — pinpython:3.13-slimand usepip install --no-cache-dir.
Try it
- Write a minimal FastAPI app locally.
- Copy the Dockerfile above, run
fly launch, deploy. - Hit your
.fly.devURL in the browser.