Skip to main content
The caddy environ command prints the environment as seen by the Caddy process.

Usage

Description

Prints the environment as seen by this Caddy process, including:
  • Caddy-specific paths (home, data, config directories)
  • Runtime information (Go version, OS, architecture)
  • All environment variables
This is useful for:
  • Debugging environment variable issues
  • Verifying Caddy can see expected variables
  • Troubleshooting path and configuration issues
  • Understanding how Caddy will behave in different environments
Security: Environments may contain sensitive data like API keys, passwords, and tokens. Be careful when sharing output from this command.

Flags

string[]
default:"[]"
Environment file(s) to load in KEY=VALUE format before printing.Useful for testing how environment files will be loaded.

Examples

Output:

Test environment file loading

This loads .env before printing, so you can verify the variables are set correctly.

Test multiple environment files

Later files override earlier ones.

Save environment to file

Compare environments

Compare development vs production:

Check specific variable

Output Format

The output has two sections:

1. Caddy Information

Caddy-specific paths and runtime info:

2. Environment Variables

All environment variables in KEY=VALUE format:

Caddy Path Variables

string
User’s home directory.On Unix: $HOME
On Windows: %USERPROFILE%
string
Directory where Caddy stores data (TLS certificates, ACME accounts, etc.).Default:
  • Linux: $HOME/.local/share/caddy
  • macOS: $HOME/Library/Application Support/Caddy
  • Windows: %APPDATA%/Caddy
Can be overridden with $XDG_DATA_HOME/caddy
string
Directory where Caddy stores configuration.Default:
  • Linux: $HOME/.config/caddy
  • macOS: $HOME/Library/Application Support/Caddy
  • Windows: %APPDATA%/Caddy
Can be overridden with $XDG_CONFIG_HOME/caddy
string
Path where Caddy saves the last running config for --resume.Usually {caddy.AppConfigDir}/autosave.json

Environment Variables in Config

If your Caddyfile uses environment variables:
You can verify they’re set:

Common Use Cases

1. Debug missing variables

2. Verify service manager environment

Environments differ between shells and service managers:

3. Test environment files

4. CI/CD debugging

In GitHub Actions or other CI:

5. Container debugging

Platform Differences

Linux

Respects XDG Base Directory specification:
  • $XDG_DATA_HOME - Data directory
  • $XDG_CONFIG_HOME - Config directory
  • $XDG_CACHE_HOME - Cache directory
If not set, falls back to $HOME/.local/share, $HOME/.config, etc.

macOS

Uses standard macOS paths:
  • ~/Library/Application Support/Caddy

Windows

Uses Windows environment variables:
  • %APPDATA%\Caddy
  • %USERPROFILE%

Plan 9

Uses $home instead of $HOME.

Security Considerations

The output includes ALL environment variables, which may contain:
  • API keys and tokens
  • Database passwords
  • Private keys
  • Session secrets
Never share the output publicly without redacting sensitive data.
To redact sensitive data:

Alternative: Print environment when running

You can also print the environment when starting Caddy:
This prints the environment and then continues to run Caddy (unlike caddy environ which exits).