← Back to all fixes
Environment variable not available inside container
The Issue
You set `export DB_URL=postgres://...` on the host but `process.env.DB_URL` is undefined inside the container.
Root Cause
Host environment variables are not automatically passed into containers. You must explicitly pass them.
How to Fix
Pass single vars: `docker run -e DB_URL=$DB_URL myapp`Pass a file: `docker run --env-file .env myapp`In Compose: use `environment:` or `env_file:` section under the serviceVerify inside the container: `docker exec <container> env | grep DB_URL`