uvicorn --reload: auto-restart FastAPI on code changes
The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
- tool
- FastAPI
- command
- uvicorn
- flag
- --reload
- default
- off
uvicorn main:app --reload runs the ASGI app app from main.py and restarts the worker process whenever a watched file changes. By default it watches *.py files in the current directory. fastapi dev main.py (FastAPI CLI) starts Uvicorn with reload enabled; fastapi run starts it without.
Usage
uvicorn main:app --reload
uvicorn main:app --reload --reload-dir src --reload-include '*.yaml'
fastapi dev main.py # same as uvicorn with --reload, for developmentRelated options
| Option | Effect |
|---|---|
| --reload | restart on file changes |
| --reload-dir DIR | directories to watch (repeatable); default: current directory |
| --reload-include GLOB | extra file patterns to watch, e.g. *.html |
| --reload-exclude GLOB | patterns to ignore |
| --reload-delay SECONDS | wait before restarting |
| --workers N | several worker processes; cannot be combined with --reload |
Watching more than .py files
Uvicorn uses watchfiles when it is installed (pip install "uvicorn[standard]"), which is faster and is required for --reload-include and --reload-exclude patterns to work beyond the defaults.
Sources
Related pages
compare · flaskFlask vs FastAPI: differences for building Python web APIsFlask is a minimal WSGI framework where you add validation and docs yourself; FastAPI is async ASGI, validates with type hints and generates OpenAPI docs.errors · expressError: listen EADDRINUSE: address already in use :::3000Node.js and Express fail with listen EADDRINUSE when another process already uses the port. Find it with lsof, ss or netstat, stop it, or listen on a free port.codes · djangoDjango HttpResponse subclasses and their status codesDjango HttpResponse subclasses and their status codes: Redirect 302, PermanentRedirect 301, NotModified 304, BadRequest 400, Forbidden 403, NotFound 404.