Uvicorn
Lightning-fast ASGI server for Python. Standard server for FastAPI and Starlette. Current version is 0.42.0 (Mar 2026). Requires Python >=3.10. The Gunicorn worker class was moved to a separate package.
Warnings
- breaking UvicornWorker moved to separate uvicorn-worker package. uvicorn.workers.UvicornWorker import path no longer works in current versions. LLM-generated Gunicorn configs still use the old path.
- breaking Python 3.8 and 3.9 support dropped. uvicorn>=0.32.0 requires Python >=3.10.
- breaking config.setup_event_loop() removed in 0.36.0 as an undocumented internal. Broke downstream packages (including uvicorn-worker<0.4.0) that called it directly.
- breaking bare pip install uvicorn has no uvloop, httptools, or watchfiles. --reload requires watchfiles; without it the flag is silently ignored on some versions.
- gotcha --workers and --reload are mutually exclusive. Using both raises an error.
- gotcha When passing workers>1 to uvicorn.run(), the app argument must be an import string like 'main:app', not an app instance. Passing an instance raises: ValueError: You must pass the application as an import string.
- gotcha uvloop is not available on Windows. uvicorn[standard] will skip uvloop on Windows silently and fall back to the default asyncio event loop. Performance characteristics differ from Linux.
Install
-
pip install uvicorn -
pip install "uvicorn[standard]" -
pip install uvicorn-worker
Imports
- UvicornWorker
from uvicorn_worker import UvicornWorker # separate package # gunicorn app:app -w 4 -k uvicorn_worker.UvicornWorker
- uvicorn.run
uvicorn.run('main:app', host='0.0.0.0', port=8000, workers=4)
Quickstart
# Development
uvicorn main:app --reload
# Production (single process)
uvicorn main:app --host 0.0.0.0 --port 8000
# Production (multiple workers — import string required)
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4
# Programmatic
import uvicorn
if __name__ == '__main__':
uvicorn.run('main:app', host='0.0.0.0', port=8000, reload=True)
# Gunicorn + UvicornWorker (install uvicorn-worker separately)
# gunicorn main:app -w 4 -k uvicorn_worker.UvicornWorker