Title: FastAPI CLI: Dev, Run, and Deploy Without the Bloat
Open Graph Title: FastAPI CLI: Dev, Run, and Deploy Without the Bloat
Description: FastAPI CLI dev run deploy: master the official CLI for development, production serving, and deployment. Avoid rookie mistakes that crash services at 3am.
Open Graph Description: FastAPI CLI dev run deploy: master the official CLI for development, production serving, and deployment. Avoid rookie mistakes that crash services at 3am.
Opengraph URL: https://thecodeforge.io/python/fastapi-cli-dev-run-deploy/
Domain: thecodeforge.io
{
"@context": "https://schema.org",
"@type": "TechArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://thecodeforge.io/python/fastapi-cli-dev-run-deploy/"
},
"headline": "FastAPI CLI: Dev, Run, and Deploy Without the Bloat",
"description": "FastAPI CLI dev run deploy: master the official CLI for development, production serving, and deployment. Avoid rookie mistakes that crash services at 3am.",
"keywords": "FastAPI CLI: Dev, Run, and Deploy Without the Bloat, Python, Intermediate, Python Libraries, FastAPI CLI dev run deploy: master the official CLI for development, production serving, and deployment. Avoid rookie mistakes that crash services at 3am.",
"proficiencyLevel": "Intermediate",
"author": {
"@type": "Person",
"@id": "https://thecodeforge.io/about/#naren",
"name": "Naren",
"url": "https://thecodeforge.io/about/"
},
"publisher": {
"@type": "Organization",
"@id": "https://thecodeforge.io/#org",
"name": "TheCodeForge",
"url": "https://thecodeforge.io",
"logo": {"@type": "ImageObject", "url": "https://thecodeforge.io/assets/og-image.png"}
},
"datePublished": "2026-07-05T00:00:00+00:00",
"dateModified": "2026-11-03T00:00:00+00:00",
"url": "https://thecodeforge.io/python/fastapi-cli-dev-run-deploy/",
"inLanguage": "en",
"educationalLevel": "Intermediate",
"image": "https://thecodeforge.io/assets/og-image.png",
"isPartOf": {"@id": "https://thecodeforge.io/#website"}
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://thecodeforge.io/"},
{"@type": "ListItem", "position": 2, "name": "Python", "item": "https://thecodeforge.io/python/"},
{"@type": "ListItem", "position": 3, "name": "FastAPI CLI: Dev, Run, and Deploy Without the Bloat", "item": "https://thecodeforge.io/python/fastapi-cli-dev-run-deploy/"}
]
}
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What's the difference between `fastapi dev` and `fastapi run`?",
"acceptedAnswer": {
"@type": "Answer",
"text": "`fastapi dev` is for development: it enables auto-reload, binds to localhost, sets log level to debug, and runs a single worker. `fastapi run` is for production: no reload, binds to 0.0.0.0, log level info, and supports multiple workers with graceful shutdown."
}
},
{
"@type": "Question",
"name": "How do I set the number of workers with FastAPI CLI?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Use the `--workers` flag with `fastapi run`: `fastapi run main.py --workers 4`. The default is 1. For dev mode, workers are forced to 1 regardless of the flag."
}
},
{
"@type": "Question",
"name": "How do I use a custom .env file with FastAPI CLI?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Use the `--env-file` option: `fastapi run main.py --env-file .env.production`. By default, the CLI loads `.env` from the current directory."
}
},
{
"@type": "Question",
"name": "Can I use FastAPI CLI with Gunicorn?",
"acceptedAnswer": {
"@type": "Answer",
"text": "No, the CLI doesn't integrate with Gunicorn. If you need Gunicorn, run Uvicorn workers directly: `gunicorn -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000 --workers 4`."
}
}
]
}
{
"@context": "https://schema.org",
"@type": "VideoObject",
"name": "FastAPI: The dev server accidentally left running in production for th",
"description": "The dev server accidentally left running in production for three weeks. Root cause: Dev server (reloader, 1 worker) used for production traffic. The fix: Use `fastapi run` with workers; keep `dev` for local only.",
"thumbnailUrl": [
"https://i.ytimg.com/vi/9sHyV4qV938/maxresdefault.jpg",
"https://i.ytimg.com/vi/9sHyV4qV938/hqdefault.jpg"
],
"uploadDate": "2026-07-06T00:00:00+05:30",
"embedUrl": "https://www.youtube.com/embed/9sHyV4qV938",
"contentUrl": "https://www.youtube.com/watch?v=9sHyV4qV938",
"publisher": {
"@id": "https://thecodeforge.io/#org"
},
"isPartOf": {
"@id": "https://thecodeforge.io/python/fastapi-cli-dev-run-deploy/"
}
}
| og:type | website |
| og:image | https://thecodeforge.io/assets/og-image.png |
| og:image:width | 1200 |
| og:image:height | 630 |
Links:
Viewport: width=device-width, initial-scale=1.0
Robots: max-image-preview:large