What Is Uvicorn? The ASGI Server That Runs FastAPI
What is Uvicorn? An ASGI web server for Python that runs FastAPI and Starlette apps. How to install and run it, workers, and a production setup.
Uvicorn is an ASGI web server for Python: the program that listens on a port and runs your FastAPI or Starlette app. The commands in this guide were run against Uvicorn 0.54.0 and FastAPI 0.162.7 on 14 November 2026. If you’ve followed a FastAPI tutorial, you’ve run uvicorn main:app --reload without necessarily knowing what Uvicorn itself is doing. It’s not part of FastAPI — it’s the layer underneath it.
Uvicorn at a glance
| What it is | An ASGI web server implementation for Python |
| Install | pip install uvicorn or uv add uvicorn |
| Run | uvicorn main:app (main is the file, app is the application object) |
| Protocols | HTTP/1.1, HTTP/2 and WebSockets, according to its documentation |
| Used by | FastAPI, Starlette and other ASGI frameworks |
| Production | Several processes with --workers, or under Gunicorn: see Gunicorn vs Uvicorn vs Hypercorn |
Run your first app
Save this as main.py:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, world!"}Then start it with Uvicorn:
uvicorn main:app --reloadmain:app means “the object named app in main.py”. Uvicorn serves it on http://127.0.0.1:8000 by default, and --reload restarts the server when you change the code. Uvicorn doesn’t need FastAPI: its own documentation’s minimal example is a bare async function that takes scope, receive and send, which is the ASGI interface that frameworks implement for you.
What Uvicorn actually is
Uvicorn is an ASGI server — a program that receives HTTP (and WebSocket) requests from the network and hands them off to your Python application code, then sends the response back. ASGI is the async successor to WSGI, the older synchronous standard that servers like Gunicorn were built for. Your FastAPI or Starlette app doesn’t talk to the network directly; it implements the ASGI interface, and Uvicorn is what actually opens the socket and speaks HTTP.
Where it fits: FastAPI vs Starlette vs Uvicorn
Think of it as three layers:
- Uvicorn — the server. Handles raw HTTP/WebSocket connections, protocol parsing, and calls your app.
- Starlette — the ASGI toolkit. Routing, middleware, request/response objects.
- FastAPI — built on top of Starlette, adding request validation, automatic docs, and dependency injection via Pydantic.
You could run a Starlette app directly on Uvicorn with no FastAPI involved at all — FastAPI is a layer of developer convenience on top of Starlette, not a replacement for either Starlette or Uvicorn.
When you’d reach for it directly
In development, uvicorn main:app --reload is the standard way to run any ASGI app locally. In production, Uvicorn is commonly run either standalone with multiple worker processes, or — more often for real deployments — managed by Gunicorn using Uvicorn’s worker class, which adds process management, graceful restarts, and worker health checks that Uvicorn alone doesn’t handle.
Uvicorn vs Gunicorn: not actually competitors
This is a common point of confusion. Gunicorn is a process manager built for WSGI apps; it doesn’t natively understand ASGI. Uvicorn provides a Gunicorn worker class specifically so you get Gunicorn’s process management with Uvicorn’s actual request handling — gunicorn -k uvicorn.workers.UvicornWorker main:app is the typical production pattern, not an either/or choice. Uvicorn’s deployment docs now mark uvicorn.workers as deprecated in favour of the separate uvicorn-worker package, so check them before copying that command. For a three-way comparison with Hypercorn, see Gunicorn vs Uvicorn vs Hypercorn.
Commands you’ll actually use
# development: restart automatically when code changes
uvicorn main:app --reload
# choose a port
uvicorn main:app --port 5000
# install with the optional extras
pip install 'uvicorn[standard]'
# run several worker processes
uvicorn main:app --workers 4Two details from Uvicorn’s own documentation: --reload and --workers are mutually exclusive, so use --reload while developing and --workers (or Gunicorn) in production, and the [standard] extras include the watchfiles package that --reload uses. In practice, passing both doesn’t fail: Uvicorn 0.54.0 printed "workers" flag is ignored when reloading is enabled and ran a single process under the reloader.
What does Uvicorn mean?
It is simply the name of the project. Uvicorn’s documentation doesn’t explain where the name comes from, so treat any origin story you read elsewhere as unverified.
The bottom line
Uvicorn is the thing actually listening on a port and speaking HTTP for nearly every modern async Python web framework. You rarely need to think about it beyond the run command — but when a deployment issue turns out to be about worker counts, connection handling, or graceful shutdowns, it’s usually Uvicorn’s configuration you’re looking at, not FastAPI’s.
Frequently Asked Questions
What is Uvicorn?
Uvicorn is an ASGI server — a program that receives HTTP and WebSocket requests from the network and hands them off to your Python application code, then sends the response back. It’s the layer underneath frameworks like FastAPI, not part of FastAPI itself.
How do FastAPI, Starlette, and Uvicorn relate to each other?
They’re three layers: Uvicorn is the server handling raw connections, Starlette is the ASGI toolkit providing routing and middleware, and FastAPI is built on top of Starlette adding request validation and automatic docs.
Is Uvicorn a competitor to Gunicorn?
No — Gunicorn is a WSGI process manager that doesn’t natively understand ASGI. Uvicorn provides a Gunicorn worker class so you get Gunicorn’s process management with Uvicorn’s actual request handling, typically run together in production.
When do you need to think about Uvicorn directly?
In development, running `uvicorn main:app —reload` locally. In production, when a deployment issue turns out to be about worker counts, connection handling, or graceful shutdowns — that’s usually Uvicorn’s configuration, not the framework’s.
What is Uvicorn in FastAPI?
The server that runs your FastAPI app. FastAPI defines your routes and validation; Uvicorn listens on a port, speaks HTTP and WebSockets, and calls your app for each request. You start it with uvicorn main:app, where main is the file and app is the FastAPI object.
Is Uvicorn a web server or a web framework?
A web server. Uvicorn describes itself as an ASGI web server implementation for Python. It does not provide routing or request handling for you; frameworks like FastAPI and Starlette do that and run on top of it.
How do I install and run Uvicorn?
Install it with pip install uvicorn (or uv add uvicorn), then run uvicorn main:app, adding —reload during development and —port to choose a port. For production, uvicorn main:app —workers 4 runs several processes.
Does Uvicorn support HTTP/2 and WebSockets?
Uvicorn’s documentation says it currently supports HTTP/1.1, HTTP/2 and WebSockets.
What does Uvicorn mean?
Uvicorn is the name of the project, an ASGI web server for Python. Its documentation does not explain where the name comes from, so any etymology you read elsewhere is guesswork.
Do I need Gunicorn with Uvicorn in production?
Not necessarily. Uvicorn can run several worker processes itself with —workers. Gunicorn in front adds its own process management, and some teams already run it. See the Gunicorn vs Uvicorn vs Hypercorn guide for the trade-offs.