In my beginner's guide to FastAPI, I showed you how to run your application using this command:
uvicorn main:app --reload
That command works perfectly fine. But FastAPI also comes with a command-line tool, the FastAPI CLI, that makes running your app even simpler. It's a small but handy tool that standardizes how you start your development server.
This guide explains what the FastAPI CLI is and how to use its two main commands: fastapi dev and fastapi run.
When you install FastAPI with its standard dependencies, it includes the FastAPI CLI.
pip install "fastapi[standard]"
This gives you access to the fastapi command in your terminal. Internally, the FastAPI CLI uses Uvicorn, a high-performance ASGI server, to run your application. Instead of typing out uvicorn commands, you can use the CLI to start your app. It automatically finds your FastAPI application instance and runs it, saving you a few keystrokes and potential typos.
The fastapi dev command is the direct replacement for uvicorn main:app --reload. It starts a development server with auto-reload enabled, so the server will restart automatically whenever you save a file.
To use it, just point it to the file containing your FastAPI app:
fastapi dev main.py
This command does the same thing as the Uvicorn command but is shorter and easier to remember. It's designed specifically for local development.
The CLI also includes a fastapi run command. This command starts your app without auto-reload, making it more stable and suitable for a production-like environment.
fastapi run main.py
By default, it also binds the server to 0.0.0.0, meaning it can accept connections from outside your local machine, which is necessary in a deployed environment.
However, you should not rely on fastapi run alone for a real production deployment. A production setup typically requires running your app with a process manager like Gunicorn and placing it behind a reverse proxy like Nginx. This provides the scalability, reliability, and security that fastapi run does not offer. For a deeper dive into optimizing Gunicorn for production, see my guide on advanced performance tuning for FastAPI.
For more on this, see my guide on deploying FastAPI with Docker.
The main benefit of the FastAPI CLI is simplicity.
fastapi dev main.py is quicker to type than uvicorn main:app --reload.main.py or app.py and an instance named app, so you often don't even need to specify the file.It's a small quality-of-life improvement that cleans up your development workflow.
The FastAPI CLI is a convenient tool for running your application during development. The fastapi dev command is a great, simple alternative to the longer Uvicorn command. While fastapi run exists, remember that a proper production deployment requires more robust tools like Gunicorn and Nginx.
1. What's the difference between fastapi dev and uvicorn main:app --reload?
They do essentially the same thing: run a development server with auto-reload. fastapi dev is just a simpler, more convenient command provided by the FastAPI CLI.
2. Can I use fastapi run for my final production deployment?
It's not recommended. For production, you should use a process manager like Gunicorn to manage Uvicorn workers. This provides better performance, reliability, and scaling. fastapi run is a good way to test your app in a production-like mode, but it's not a full deployment solution.
3. What if my main file or app instance has a different name?
The FastAPI CLI automatically looks for common patterns like main.py or app.py with an instance named app. If your setup is different, the CLI might not find your app. In that case, you can stick with the explicit uvicorn command, which lets you specify the path precisely (e.g., uvicorn my_project.server:my_app --reload).
About the Author
David Muraya is a Solutions Architect specializing in Python, FastAPI, and Cloud Infrastructure. He is passionate about building scalable, production-ready applications and sharing his knowledge with the developer community. You can connect with him on LinkedIn.
Related Blog Posts
Enjoyed this blog post? Check out these related posts!

How to Set Up Logging in FastAPI
A clear, practical guide to logging in FastAPI, covering log levels, configuration, and best practices for real-world applications.
Read More...

Blocked by CORS in FastAPI? Here's How to Fix It
Solving Cross-Origin Errors Between Your Frontend and FastAPI
Read More...

How to Protect Your FastAPI OpenAPI/Swagger Docs with Authentication
A Guide to Securing Your API Documentation with Authentication
Read More...

A Practical Guide to FastAPI Security
A Comprehensive Checklist for Production-Ready Security for a FastAPI Application
Read More...
Contact Me
Have a project in mind? Send me an email at hello@davidmuraya.com and let's bring your ideas to life. I am always available for exciting discussions.