Docs
Docs / Configuration / Environment variables

Environment variables

Environment variables let you change behaviour between machines, environments and deployments without editing code or the config file.

On this page: Precedence · Variable reference · Setting variables · Troubleshooting

Precedence

When the same setting can be provided in more than one place, the first match below wins:

  1. Command-line flags
  2. Environment variables
  3. The config file (config.yaml)
  4. Built-in defaults

Variable reference

Variable names are case-sensitive and always uppercase. Boolean values accept true/false, 1/0, or yes/no.

VariableDefaultDescription
APP_ENVdevelopmentSelects the active profile. One of development, staging, production.
APP_PORT8080TCP port the server listens on.
APP_LOG_LEVELinfoMinimum log level: debug, info, warn, error.
APP_DATA_DIR./dataDirectory used for local state and caches.
APP_API_KEYnoneKey used to authenticate outbound API calls. Treat as a secret.
APP_CONFIG_FILE./config.yamlPath to an alternate config file.
APP_TIMEOUT_SECONDS30Timeout applied to outbound requests.
APP_TELEMETRYtrueSet to false to disable anonymous usage reporting.

Setting variables

Shell (macOS, Linux)

export APP_ENV=staging
export APP_LOG_LEVEL=debug
./app serve

One-off for a single command

APP_PORT=9000 ./app serve

Windows PowerShell

$env:APP_ENV = "staging"
.\app.exe serve

.env file

If a .env file exists in the working directory, it is loaded at startup. Variables already set in the real environment are not overwritten.

# .env
APP_ENV=development
APP_LOG_LEVEL=debug
APP_DATA_DIR=./.local-data
Do not commit .env files that contain secrets. Add them to .gitignore and use your platform's secret store in production.

Troubleshooting

My variable is ignored

Check three things: the exact spelling and case of the name, that the variable is exported (not just set in the current shell session as a local variable), and that a command-line flag is not overriding it.

Print the resolved configuration

To see the final values the process will use, along with where each one came from:

./app config show --sources

Invalid value

If a value cannot be parsed, the server exits at startup with code 2 and a message naming the variable. See error codes for the full list.