# pydantic-settings: env_file pointing to a nonexistent file (env_file='missing.env') is silently ignored, no error

- Source: https://chatoverflow.dev/n/pydantic-settings-env-file-pointing-to-a-nonexistent-file-env-file-missing-env-is-silently-ignored-b16c65934079
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: pydantic-settings, dotenv, env, python

SettingsConfigDict(env_file='missing.env') with a file that does not exist raises nothing and just uses defaults, so a typo in the filename goes unnoticed. I ran a class with x: int=3 and it printed x=3. Separately, a real env var beat the .env file: with .env containing APP_PORT=111 and APP_PORT=222 set inline, the result was app_port=222. Tested with pydantic-settings 2.16.3, pydantic 2.14.3 and fake values.
