Web Servers

ASGI and WSGI compatible web servers.

In production, Gunicorn serves WSGI apps like Django, and Uvicorn ASGI apps like FastAPI. Need a Python web server on Windows? Waitress runs WSGI there.

How to choose:

  • A WSGI app (Flask, Django) on Linux or macOS: Gunicorn
  • An ASGI app (FastAPI, Starlette): Uvicorn
  • A WSGI app on Windows, or a server in pure Python: Waitress
  • One server for both ASGI and WSGI apps, or throughput above all: Granian
  • An app on Trio, or HTTP/3 from the Python server: Hypercorn

Listed in editorial order, grouped by use case. Click a column header to re-sort the whole list.

Press / to search. Tags open their category. Click a row for details.

Search and filter

Results

Row number Tags

ASGI 3 projects

A lightning-fast ASGI server implementation.
Kludex/github.com/Kludex/uvicorn /11,050 stars /
A Rust HTTP server for Python apps built on Hyper and Tokio, supporting WSGI/ASGI/RSGI.
An ASGI and WSGI server based on Hyper libraries and inspired by Gunicorn.
pgjones/github.com/pgjones/hypercorn /1,621 stars /

WSGI 2 projects

A pre-fork WSGI server with a native ASGI worker, ported from Ruby's Unicorn project.
benoitc/github.com/benoitc/gunicorn /10,717 stars /
Multi-threaded, powers Pyramid.
Pylons/github.com/Pylons/waitress /1,602 stars /

Web Servers guide

Gunicorn is a pre-fork server: one process manages a pool of worker processes. It's built for Unix. With its default sync workers, your proxy must buffer slow clients, or Gunicorn is open to denial-of-service attacks. Start with (2 × CPU cores) + 1 workers and adjust under load. For long blocking calls, streaming, or WebSockets, switch to async workers like gevent.

Uvicorn is an ASGI web server. In production, run it under a process manager. Its built-in one starts workers with --workers and restarts any that die, and its docs also cover running Uvicorn workers under Gunicorn. In a container, run a single Uvicorn process and let your orchestrator scale the number of containers.

Granian is a Rust HTTP server that serves ASGI, WSGI, and RSGI apps from one package. Its README suggests it when you care about throughput above all, and not when you want pure Python or your app relies on Trio or gevent. Pass --interface asgi or --interface wsgi, since the default is RSGI. Start with one worker per CPU core, or one per container on Docker or Kubernetes, rather than numbers suggested for other servers.

Hypercorn is an ASGI server inspired by Gunicorn. It speaks HTTP/1 and HTTP/2, with WebSockets over both, and runs on Trio as well as asyncio. For HTTP/3, install its h3 extra. Its docs recommend setting server_names to the hosts you serve, to block DNS rebinding attacks.

Waitress is a pure-Python WSGI server with no dependencies outside the standard library, and it runs on both Unix and Windows. Waitress doesn't support TLS itself, so put a reverse proxy in front of it for HTTPS.

Put a proxy like Nginx in front: Gunicorn's docs strongly recommend it, and Uvicorn's recommend it for resilience. Behind a proxy, tell your server which proxies to trust for X-Forwarded-* headers, since any client can set them. Uvicorn and Gunicorn take --forwarded-allow-ips, Granian trusted_hosts, Hypercorn ProxyFixMiddleware, and Waitress trusted_proxy. In Uvicorn, Gunicorn, Granian, and Waitress, trust every address with * only when no client can reach the server directly.

Know a project that belongs here?

Tell us what it does and why it stands out.