What is uvicorn.run()?
uvicorn.run() is the programmatic interface to Uvicorn, Python's lightning-fast ASGI web server. Unlike the command-line interface, it allows you to start and configure your server directly from Python code, giving you complete control over server lifecycle and configuration.
Perfect for production deployments, testing environments, and applications that need dynamic server configuration, uvicorn.run() is the go-to choice for modern Python web applications built with FastAPI, Starlette, and other ASGI frameworks.
Requirements: Python 3.10+ (as of uvicorn 0.40.0). Python 3.14 is supported since uvicorn 0.38.0. For optimal performance, install with pip install uvicorn[standard] which includes uvloop and httptools. The latest version is 0.54.0 (September 2026). See what changed recently.
Quick Start
Get up and running with uvicorn.run() in seconds:
import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"message": "Hello, World!"}
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
That's it! Your ASGI application is now running with automatic reloading enabled for development.
Explore the Guide
Each page covers one topic in depth:
Parameters Reference
Every uvicorn.run() parameter with its type, options and default.
Real-World Examples
Production, auto-reload, Config and Server objects, factory, environment-based config and test server examples.
HTTPS, TLS and HTTP/2
HTTPS, mutual TLS, ssl_context_factory and experimental HTTP/2 with zttp.
Deployment & Best Practices
Workers, SIGHUP restarts, reverse proxies, UNIX sockets, Gunicorn, graceful shutdown and best practices.
Upgrading uvicorn
Recent uvicorn changes that affect uvicorn.run(), and deprecations to handle when upgrading.