# How configuration works

Learn how dimmi maps settings to environment variables in /opt/dimmi/.env and how to update them safely with dimmictl.

A self-hosted dimmi loads its settings from environment variables stored in `/opt/dimmi/.env`.

## Environment variable naming

Every config key maps to an uppercase variable starting with `DIMMI_`, using double underscores (`__`) between nesting levels:

| Config key | Environment variable |
| --- | --- |
| `log.level` | `DIMMI_LOG__LEVEL` |
| `auth.sessions.idle_lifetime` | `DIMMI_AUTH__SESSIONS__IDLE_LIFETIME` |
| `mail.mailers.system.driver` | `DIMMI_MAIL__MAILERS__SYSTEM__DRIVER` |

- **Lists:** comma-separated values, such as `totp,passkey`.
- **Durations:** number plus unit, such as `15m` or `336h`.

See [Configuration options](/self-hosting/configuration-options/) for the full list of variables.

## Change a setting with `dimmictl set`

```bash
dimmictl set DIMMI_LOG__LEVEL=debug
```

`dimmictl set` updates `/opt/dimmi/.env` and restarts only the affected services. Pipe secrets via stdin so they stay out of your shell history:

```bash
dimmictl set <<'EOF'
DIMMI_AI__MANAGED__ANTHROPIC__API_KEY=<anthropic_api_key>
EOF
```

Two groups of variables behave differently:

- **Managed by `compose.yaml`:** app URL, database, Redis/Valkey, file storage, HTTP listeners, and roles (`DIMMI_APP__URL`, `DIMMI_DATABASE__URL`, `DIMMI_REDIS__URL`, `DIMMI_FILESYSTEMS__*`, `DIMMI_HTTP__*`, `DIMMI_APP__ROLES`) are wired by Compose and cannot be overridden in `.env`.
- **Compose and Caddy variables:** `APP_DOMAIN`, `COMPOSE_PROFILES`, `NETWORK_SUBNET`, and `CADDY_TLS` have no `DIMMI_` prefix. `dimmictl set` restarts Caddy or starts ClamAV automatically when you change them.

## Inspect active settings

Print the resolved config with secrets masked as `[redacted]`:

```bash
docker compose -f /opt/dimmi/compose.yaml exec web /dimmi config:show
```

dimmi validates settings on startup. If an invalid value stops the container from booting, `dimmictl logs web` names the offending key.

## Protect your app key

`DIMMI_APP__KEY` encrypts secrets saved inside Postgres. The installer generates it once; losing or changing it makes encrypted database values unreadable forever. Always include `/opt/dimmi/.env` in your [backups](/self-hosting/backups/).

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
