Run
uvicorn <module>:<app>
Serve an ASGI app
uvicorn --factory <module>:<func>
Treat app as a factory
The function takes no arguments and returns the app.
uvicorn <module>:<app> --reload
Auto-restart on file change
Development only.
uvicorn <module>:<app> --workers
<n>
Run n worker processes
Defaults to $WEB_CONCURRENCY, else 1.
uvicorn --app-dir <dir>
<module>:<app>
Look for the app in a directory
uvicorn --env-file <file>
<module>:<app>
Load environment from a file
uvicorn --interface wsgi <module>:<app>
Serve a WSGI app
uvicorn --lifespan <auto|on|off>
Control startup/shutdown events
uvicorn --version
Print the version
uvicorn --help
List all options
python -m uvicorn <module>:<app>
Run via the interpreter
Uses the interpreter's environment, handy in venvs.
Workers and limits
--workers <n>
Number of worker processes
--limit-concurrency <n>
Answer 503 above n connections
--limit-max-requests <n>
Restart a process after n requests
--limit-max-requests-jitter <n>
Stagger those restarts
--timeout-keep-alive <sec>
Idle keep-alive timeout (default 5)
Keep it above the proxy's upstream keep-alive time.
--timeout-graceful-shutdown <sec>
Max wait on shutdown
kill -HUP <pid>
Gracefully restart workers
Works with --workers, not on Windows.
kill -TTIN <pid> / kill -TTOU <pid>
Add / remove one worker
Logging
--log-level <level>
critical, error, warning, info, debug, trace
--no-access-log
Silence request lines
--access-log
Enable request lines (default)
--use-colors / --no-use-colors
Force or disable coloured logs
--log-config <file>
Logging config (.ini, .json, .yaml)
Log config from a dict
uvicorn main:app --log-config logging.json
HTTPS and proxies
--ssl-keyfile <key> --ssl-certfile <crt>
Serve HTTPS directly
--ssl-keyfile-password <pw>
Password for the key
--ssl-ca-certs <file>
CA bundle for client certs
--ssl-cert-reqs <n>
Require a client certificate
Value from Python's ssl module (0 none, 2 required).
--proxy-headers
Read X-Forwarded-For and -Proto
On by default; only trusted IPs are honoured.
--no-proxy-headers
Ignore forwarded headers
--forwarded-allow-ips <ips>
Trusted proxy IPs or sockets
Default 127.0.0.1,::1 (or $FORWARDED_ALLOW_IPS). '*'
trusts everyone: only if your proxy strips client-sent
headers.