Environment Variables¶
Manage secrets and environment variables on your cloud server.
Quick Reference¶
| Command | Description |
|---|---|
dango remote env set KEY=VALUE | Set or update a variable |
dango remote env get KEY | Display a variable (masked) |
dango remote env list | List all variables (masked) |
dango remote env delete KEY | Remove a variable |
When to Use Env Vars vs secrets.toml¶
| Use Case | Where to Store |
|---|---|
Cloud provider tokens (DIGITALOCEAN_TOKEN) | Environment variable |
Object storage keys (SPACES_ACCESS_KEY) | Environment variable |
| Source API keys (Stripe, HubSpot, etc.) | .dlt/secrets.toml |
| OAuth tokens (Google, Facebook, etc.) | .dlt/secrets.toml (managed by OAuth flow) |
Admin password (DANGO_ADMIN_PASSWORD) | Environment variable |
General rule: credentials used by Dango itself (cloud, backups, auth) go in .env. Credentials used by dlt for data ingestion go in .dlt/secrets.toml. Both files live on the server at /srv/dango/project/ and are never synced by dango remote push.
Setting Variables¶
- Creates the
.envfile if it doesn't exist (with0600permissions — readable only by the file owner) - Updates the value if the key already exists
- The key cannot be empty and the format must be
KEY=VALUE
Set multiple variables with separate commands:
dango remote env set SPACES_ACCESS_KEY=DO00EXAMPLE123
dango remote env set SPACES_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLE
dango remote env set SPACES_REGION=nyc3
dango remote env set SPACES_BUCKET=my-dango-backups
Viewing Variables¶
View a single variable:
List all variables:
SPACES_ACCESS_KEY=***
SPACES_SECRET_KEY=***
SPACES_REGION=***
SPACES_BUCKET=***
DIGITALOCEAN_TOKEN=***
5 variable(s) total
Note
Values are always masked in the output. To see actual values, use dango remote ssh and inspect the file directly: cat /srv/dango/project/.env
Deleting Variables¶
Returns an error if the variable doesn't exist.
Remote .env Location¶
Environment variables are stored at:
This file has 0600 permissions (owner read/write only). The env commands connect to the server as the dango user for project file operations, following the two-SSH-user pattern (root for system operations, dango for project files).
Common Variables¶
| Variable | Used For |
|---|---|
DIGITALOCEAN_TOKEN | DigitalOcean API access (deploy, resize, migrate, destroy) |
SPACES_ACCESS_KEY | DigitalOcean Spaces access key (backups) |
SPACES_SECRET_KEY | DigitalOcean Spaces secret key (backups) |
SPACES_REGION | Spaces region slug, e.g., nyc3 (backups) |
SPACES_BUCKET | Spaces bucket name (backups) |
DANGO_ADMIN_PASSWORD | Admin password for automated setups |
Cloud Deploy Token Storage¶
When running deployment commands (dango deploy, dango remote push, etc.), the DigitalOcean API token is resolved in this order:
- Environment variable —
DIGITALOCEAN_TOKENin your local shell - Project credentials —
.dango/credentialsin the project directory - User credentials —
~/.dango/credentialsin your home directory
The first match wins. Tokens saved during dango deploy are written to the project credentials file.
Troubleshooting¶
Variable not taking effect¶
Environment variables require a service restart to take effect:
Then on the server:
For Docker services (Metabase), the variables are passed through docker-compose.yml — rebuild the container:
Permission denied¶
The .env file may have incorrect permissions. Fix via SSH:
dango remote ssh
sudo chown dango:dango /srv/dango/project/.env
sudo chmod 600 /srv/dango/project/.env
Invalid format¶
The argument must contain an = separator and the key cannot be empty:
# Wrong
dango remote env set MYVAR
dango remote env set =value
# Right
dango remote env set MYVAR=value
dango remote env set MYVAR=value with spaces
Next Steps¶
- Remote Management — push, rollback, and other server commands
- Backups — configure Spaces credentials for automated backups
- Authentication — manage users and sessions