Quick answer
Each non-empty line in a .env file must be either a comment (starting with #) or a KEY=value pair.
.env Invalid Line
Each non-empty line in a .env file must be either a comment (starting with #) or a KEY=value pair. Missing =, invalid key characters, or malformed lines cause validation errors.
Common causes
- Line without = (e.g. KEY only or value only).
- Key containing spaces or special characters (key must be letters, digits, underscore).
- Key starting with a number (key must start with letter or underscore).
How to fix
- Use KEY=value format; key and value are separated by the first =.
- Key must start with a letter or underscore and contain only letters, digits, and underscores.
- Use comments (#...) for lines that are not variables.
- Validate with Env File Validator to get the exact line.
Examples
Bad
NODE ENV=production
Good
NODE_ENV=production
FAQ
- Can .env keys have spaces?
- No. Keys must start with a letter or underscore and contain only letters, digits, and underscores.
- What if my value contains =?
- The first = separates key from value; the rest is part of the value.
Fix it now
Try in validator (prefill this example)