Environment Variables
Keep secrets out of your code. Your app reads them from its environment at every start.
Updated Dec 1, 2026Environment variables are key and value pairs given to your app when it starts. Use them for anything you should not commit to GitHub, like a Discord bot token, an API key or a database URL.
Open the deployment, then Environment. It needs the Environments permission.
Add a variable
- Click Add variable (or Add first variable on an empty list).
- Enter the Key, for example
DISCORD_TOKEN. - Enter the Value.
- Check Secret for anything sensitive.
- Save.
Saving restarts the deployment so the new value reaches your code. If the deployment is stopped, the value is used at the next start.
Read it in your code
Node.js
const token = process.env.DISCORD_TOKEN;
Python
import os
token = os.environ["DISCORD_TOKEN"]
Java
String token = System.getenv("DISCORD_TOKEN");
Go
token := os.Getenv("DISCORD_TOKEN")
You do not need a .env file or the dotenv package on Bot-Hosting. The variables are already in the environment. A .env file in your files still works if your code loads it, but variables from this tab are safer, since they never sit in your files or your repository.
Secrets
A variable marked Secret is hidden in the interface and in logs. Click the eye to see it, or Copy value to copy it. Make visible and Make secret switch it at any time, without restarting the deployment.
Only people with the Environments permission can see the values. Someone you shared the deployment with for the console only never receives them. See Manage Access.
Edit and delete
- Click Edit on a row, change the value, and click Save. Esc cancels.
- Delete variable asks for confirmation. It cannot be undone.
Table view and raw .env view
The View switch toggles between Table and Raw .env.
The raw view shows your variables as KEY=VALUE, one per line. You can paste a whole .env file there and save it in one go, or use Copy all to copy your variables. The panel checks every line and lists the issues to fix before saving.
Saving the raw view replaces all your own variables with what is in the text. A variable you remove from the text is deleted. System variables are never touched.
Limits
| Limit | Value |
|---|---|
| Variables per deployment | 50 (system variables not counted) |
| Key length | 128 characters, no spaces and no = |
| Value length | 4,096 characters |
| Raw .env text | 64 KB |
System variables
Some variables are managed by Bot-Hosting and marked System. They are read-only here, and you cannot create a variable with their name.
| Variable | Meaning | Changed from |
|---|---|---|
SERVER_PORT |
The primary port your app must listen on | Network |
SERVER_IP |
The address the container listens on | Automatic |
SERVER_MEMORY |
The RAM given to the deployment, in MB | Resources |
STARTUP_FILE |
Your entry file | Startup |
RUNTIME_VERSION |
The runtime or engine version | Startup |
STARTUP |
The start command | Startup |
P_SERVER_UUID, P_SERVER_LOCATION |
Internal identifiers of the deployment | Automatic |
Database deployments also get their generated credentials as system variables (for example PGPASSWORD or SERVER_PASSWORD). Change them with Regenerate password in the Database tab, see Databases.
Troubleshooting
- My code reads
undefined. Check the exact spelling of the key, then restart the deployment. - "Variable already exists". Each key can only exist once. Edit the existing one.
- "is managed by the system". You used a reserved name. Pick another key, or change the setting from Startup or Network.
- Invalid token errors. See Invalid Token.