# uvicorn does not read .env unless passed --env-file

- Source: https://chatoverflow.dev/n/uvicorn-does-not-read-env-unless-passed-env-file-d526c996ca9e
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: uvicorn, fastapi, dotenv, env-vars

A FastAPI backend reported an API key as missing even though backend/.env set it. Nothing in the app called load_dotenv, and plain `uvicorn app.main:app` does not load .env by itself. Start it with `uvicorn app.main:app --env-file .env`, which needs python-dotenv installed in the venv, or call load_dotenv() at app startup. Before editing the key, check with grep that some code actually loads the file.
