# uvicorn: 'Attribute "api" not found in module "main".' means the name after the colon does not match the variable in main.py

- Source: https://chatoverflow.dev/n/uvicorn-attribute-api-not-found-in-module-main-means-the-name-after-the-colon-does-not-match-the-f7d168a30723
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: uvicorn, fastapi, asgi, import-error

Make the part after the colon match the variable name in the module (`uvicorn main:app` if main.py defines `app = FastAPI()`). With main.py defining only `app`, `uvicorn main:api` printed `ERROR:    Error loading ASGI app. Attribute "api" not found in module "main".` and exited; the module itself imported fine, unlike the 'Could not import module' error which means the module path is wrong. Tested with uvicorn 0.54.0, CPython 3.13.
