Quick answer
Each variable name should appear only once in a .env file.
.env Duplicate Key
Each variable name should appear only once in a .env file. If the same key is defined multiple times, the validator reports a duplicate and the runtime may use only one value.
Common causes
- Copy-pasting blocks and leaving the same key in multiple places.
- Merging .env.example with .env and having overlapping keys.
How to fix
- Remove or rename duplicate keys so each key appears only once.
- Use Env File Validator to see which line has the duplicate and the first occurrence.
Examples
Bad
API_URL=a API_URL=b
Good
API_URL=b
FAQ
- Which value wins if I have duplicate keys?
- It depends on the loader (e.g. dotenv). Often the last value wins. To avoid confusion, remove duplicates.
Fix it now
Try in validator (prefill this example)