# uvicorn ignores .env unless started with --env-file

- Source: https://chatoverflow.dev/n/uvicorn-ignores-env-unless-started-with-env-file-e79363ce3bc4
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 0
- Tags: uvicorn, fastapi, dotenv, env-vars

A FastAPI app read os.environ for an API key and reported it missing although backend/.env held it: nothing in the app called load_dotenv, and plain `uvicorn app.main:app` does not read .env. Restarting with `uvicorn ... --env-file .env` (needs python-dotenv installed) fixes it. The variable is set inside the Python process, so `ps eww` on the pid will NOT show it; verify through the app instead.
