← All notes

Run a Django project on Uvicorn as an ASGI app

Answer: Uvicorn is an ASGI server based on uvloop and httptools, with an emphasis on speed. For a typical Django project, invoking Uvicorn would look like python -m uvicorn myproject.asgi:application. A Starlette application serves incoming HTTP and WebSocket requests.

Run Django in Uvicorn

Install Uvicorn with python -m pip install uvicorn. When Uvicorn is installed, a uvicorn command is available which runs ASGI applications. Call Uvicorn with a module that contains an ASGI application object, then a colon and the application name. This starts a process listening on 127.0.0.1:8000. Your project must be on the Python path; run the command from the same directory as manage.py. In development mode, add --reload so the server reloads when a file is changed on disk.

Gunicorn is a robust web server with process monitoring and automatic restarts, which can help when running Uvicorn in production. To install Uvicorn and Gunicorn, use python -m pip install uvicorn uvicorn-worker gunicorn. Then start Gunicorn using the Uvicorn worker.

The ASGI application object

Starlette includes an application class Starlette that nicely ties together all of its other functionality. You pass routes (a list of routes to serve incoming HTTP and WebSocket requests), middleware (a list of middleware to run for every request), and an optional lifespan. In the docs, a lifespan function prints Startup, then yield, then Shutdown.

| myproject.asgi:application | --reload | |---|---| | myproject.asgi:application | Module and the ASGI application name | | --reload | Reload when a file is changed on disk | | uvicorn-worker | A Gunicorn worker | | lifespan | Startup, yield, and Shutdown |

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Django (GitHub docs), How to use Django with Uvicorn; Starlette docs, Applications. BSD-3-Clause; BSD-3-Clause. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Django (GitHub docs), How to use Django with Uvicorn; Starlette docs, Applications. BSD-3-Clause; BSD-3-Clause.

Cite this

Permanent ID: iil:note:a69jd6yz

iinventedlight. 2026. "Run a Django project on Uvicorn as an ASGI app." iinventedlight Library, iil:note:a69jd6yz, version of 2026-11-19. https://iinventedlight.com/library/notes/django-asgi-uvicorn/. License: CC-BY-4.0.

@misc{iil_note_a69jd6yz,
  author = {{iinventedlight}},
  title = {{Run a Django project on Uvicorn as an ASGI app}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/django-asgi-uvicorn/},
  note = {Permanent ID iil:note:a69jd6yz. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/django-asgi-uvicorn.md.