Environment Variables
↓ Download .mdEnvironment Variables
Configure environment variables for your application securely.
Adding Variables
- On the app edit screen, go to the Environment Variables section
- Add variables in
KEY=valueformat, one per line - Click Save & Restart to apply
DATABASE_URL=postgresql://user:pass@localhost:5432/app
REDIS_URL=redis://default:pass@localhost:6379
API_KEY=sk-abc123
NODE_ENV=productionBest Practices
Never put secrets in code
Always use environment variables for:
- Database connection strings
- API keys and tokens
- Passwords and credentials
- External service URLs
Use descriptive names
# Good
DATABASE_URL=...
SMTP_HOST=...
STRIPE_SECRET_KEY=...
# Avoid
DB=...
HOST=...
KEY=...Common Variables by Framework
Node.js / Express / Next.js
NODE_ENV=production
PORT=3000
DATABASE_URL=...Python / Django
DJANGO_SETTINGS_MODULE=myapp.settings.production
DATABASE_URL=...
SECRET_KEY=...
ALLOWED_HOSTS=*Go
PORT=8080
DATABASE_URL=...
GIN_MODE=releaseReferencing Other Apps
Since all apps in a stack run in the same pod, they communicate via localhost. Each service uses its default port:
# PostgreSQL in the same stack
DATABASE_URL=postgresql://user:pass@localhost:5432/defaultdb
# Redis in the same stack
REDIS_URL=redis://default:pass@localhost:6379
# MongoDB in the same stack
MONGO_URL=mongodb://user:pass@localhost:27017/defaultdb?authSource=adminWhen Variables Are Applied
Variables are injected into the container at startup. This means:
- Save & Restart is required to apply changes
- Your application reads variables via
process.env(Node.js),os.environ(Python),os.Getenv(Go), etc. - Variables are not visible in build logs