Missing required environment variable in config
Quick summary
Your config references an environment variable that is not defined — the application fails to start.
Why this happens
The environment variable is not set in the container, pod, or CI environment
The variable name in the config does not match the name in the environment
The .env file is not loaded or is missing the required variable
Minimal example
# docker-compose.yml
services:
app:
image: myapp:latest
environment:
- DATABASE_URL=${DATABASE_URL} # not set — app fails to start# docker-compose.yml
services:
app:
image: myapp:latest
environment:
- DATABASE_URL=postgres://user:pass@db:5432/mydb # value provided
- NODE_ENV=productionProviding the DATABASE_URL value in the environment allows the application to start successfully.
How to diagnose
Check the error message for the missing environment variable name
Verify the variable is set in the container environment or .env file
Compare the variable name in the config with the name in the environment for typos
How to fix
Set the missing environment variable in the container, pod, or CI configuration
Correct the variable name in the config to match the environment
Add the variable to the .env file and ensure the application loads it
How to prevent
Validate required environment variables at startup and fail fast with a clear message
Use a config schema and environment validation library to catch missing variables early
Related Resources
Related Glossary
Related Lessons
- Configuration
Learn about env vars.