uvicorn
An ASGI web server, for Python. 🦄
A fast Python web server that handles HTTP and WebSocket connections and passes them to your app code, enabling many simultaneous connections, the standard server for FastAPI and Starlette apps.
Uvicorn is a web server for Python that handles incoming HTTP and WebSocket connections and passes them to your application code. When you build a web app in Python, you need something that actually listens on a port, accepts requests from browsers, and routes them to the right function in your code. Uvicorn is that layer, sitting between the internet and your application.
It implements a standard called ASGI, which stands for Asynchronous Server Gateway Interface. The important thing about this standard is the word asynchronous: uvicorn can handle many connections at the same time without waiting for each one to finish before starting the next. This makes it well suited for applications that involve things like chat, real-time updates, or any situation where connections stay open for a while. Older Python servers used a different standard called WSGI that handled requests one at a time, which created bottlenecks for these use cases.
Installing uvicorn with its optional dependencies adds faster components: a high-performance event loop called uvloop and a faster HTTP parser called httptools. The basic install uses pure Python implementations that work everywhere, while the standard install swaps in these faster pieces where the platform supports them.
Uvicorn is typically used as the server for FastAPI and Starlette applications. You start it from the command line by pointing it at your application file and it handles everything from there, including auto-reloading during development when files change.
This repository is a fork maintained by Kludex. The upstream project lives at github.com/encode/uvicorn. Both share the same package published to PyPI under the name uvicorn. The README is short and the project is well documented at uvicorn.dev.
Where it fits
- Serve a FastAPI or Starlette application with support for many simultaneous connections including WebSockets
- Enable real-time features like chat or live updates in a Python app using async WebSocket support
- Speed up local development with auto-reload so the server restarts automatically when you edit files
- Add faster event loop and HTTP parsing by installing the standard extras package alongside uvicorn