# Environment variables

> The settings you can put in .env, what each does, and when Songstress reads it.

Page: https://songstress.app/docs/reference/configuration/

Put these in the `.env` beside your `compose.yaml`, then run `docker compose up -d` to apply them. The
[compose file](/docs/getting-started/install-docker-compose/) passes each one to the container.

## When Songstress reads them [#when-songstress-reads-them]

Most take effect each time the container starts. A few only set things up the first time, and after that you change
them in the app:

- **The admin pair** makes the admin account only while the server has no users.
- **The acquisition settings** are read once, on the first start. Change them later in
  **Manage ▸ Acquisition ▸ Settings**.
- **The Spotify, Last.fm and VPN connections** are set up when they don't exist yet.
- **`MUSIC_LIBRARIES`** adds new libraries at every start, and never removes one.
- **The `SMTP_` settings** reach the sign-in mailer the first time. See [Email and notifications](/docs/admin/email/).

## The basics [#the-basics]

| Variable | Default | What it does |
| --- | --- | --- |
| `MUSIC_DIR` | none | The folder that holds your music, on this machine. Required. |
| `SONGSTRESS_TAG` | `edge` | Which release to run: `latest`, a version like `v0.49.0`, or `edge` for the newest build. |
| `TZ` | `UTC` | Your time zone. |
| `PUID`, `PGID` | the music folder's owner | The user and group Songstress runs as. |
| `SONGSTRESS_PORT` | `8090` | The port the web app and every app connect to. |

## Accounts and access [#accounts-and-access]

| Variable | Default | What it does |
| --- | --- | --- |
| `SONGSTRESS_ADMIN_EMAIL`, `SONGSTRESS_ADMIN_PASSWORD` | empty | Your admin account, made at the first start. Empty: you create it in the app. |
| `SONGSTRESS_PUBLIC_URL` | empty | The address people use. Invite and reset links point there. When set, it wins over the app's setting at every start. |
| `SONGSTRESS_SECRET_KEY` | generated | The key that seals connected accounts' and extensions' sign-ins. Empty: Songstress makes one in `data/songstress-secret.key`. |

## Email [#email]

| Variable | Default | What it does |
| --- | --- | --- |
| `SMTP_HOST`, `SMTP_PORT` | empty, `587` | Your mail server. Empty turns email off. |
| `SMTP_USERNAME`, `SMTP_PASSWORD` | empty | Its sign-in. |
| `SMTP_FROM` | the admin email | Who the mail comes from. |
| `SMTP_TO` | empty | Who gets the server's notification emails. |
| `SMTP_STARTTLS` | `true` | `false` uses TLS from the start, as on port 465. |

## Privacy and updates [#privacy-and-updates]

| Variable | Default | What it does |
| --- | --- | --- |
| `ENABLE_TELEMETRY` | `true` | `false` turns off diagnostics for the server and every app signed in to it. See [Security and privacy](/docs/admin/security/). |
| `UPDATE_CHECK` | `on` | `off` stops checking for new releases. |

## Jam voice [#jam-voice]

| Variable | Default | What it does |
| --- | --- | --- |
| `VOICE_PORT` | `8093` | Voice's port, UDP and TCP, the same inside and out. |
| `VOICE_STUN` | empty | Where voice asks how its port looks from the internet. Empty: a public server. `off`: never ask. |

## Room to work [#room-to-work]

| Variable | Default | What it does |
| --- | --- | --- |
| `SONGSTRESS_MEM_LIMIT` | `4g` | The most memory the container may use. |
| `SONGSTRESS_CPUS` | `0` | The most processors it may use. `0` means no limit. |
| `SONGSTRESS_TMP_SIZE` | `1536m` | Space for temporary files, inside the memory limit. |
| `ARTWORK_CACHE_MB` | `2048` | Space for resized covers, in MB. The oldest go first. |
| `TRANSCODE_LIVE_STREAM` | `1` | `0` waits for a converted song to finish before it plays. |
| `TRANSCODE_LIVE_MAX` | `8` | How many songs may play while they convert, server-wide. |
| `WRAPPED_REEL_MODE` | `motion` | `poster` makes lighter Wrapped videos, one still per slide. |
| `LOG_LEVEL` | `INFO` | How much the worker logs: `DEBUG`, `INFO`, `WARNING` or `ERROR`. |

## Libraries and acquisition [#libraries-and-acquisition]

| Variable | Default | What it does |
| --- | --- | --- |
| `MUSIC_LIBRARIES` | `Main=/music` | Your libraries, as `Name=/path`, separated by `;`. See [Compose files](/docs/reference/compose/#several-libraries). |
| `SWEEP_CRON` | `0 */6 * * *` | When the upgrade sweep runs. |
| `WORKERS` | `5` | How many downloads run at once. |
| `DURATION_TOLERANCE_S` | `3` | How many seconds a found song's length may differ from yours. |
| `SERVICE_ORDER` | empty | The order of sources to try. Empty: the built-in order. |
| `UPGRADE_IMPORTED` | `true` | `false` leaves the songs from your music folder as they are, from the first start. See [Your music folder](/docs/admin/import/#upgrades). |
| `DISCOGRAPHY_OUTPUT_TEMPLATE`, `FILENAME_TEMPLATE` | empty | Folder and file names for new downloads. Empty: `{album_artist}/{album}` and `{track_prefix}{title}`. |
| `RETRY_TRANSIENT_HOURS` | `6` | When to retry after a passing failure. |
| `RETRY_NOMATCH_DAYS` | `30` | When to look again for a song that wasn't found. |
| `YTDLP_COOKIES_FILE` | empty | Cookies for YouTube Music downloads. |

## Services [#services]

| Variable | Default | What it does |
| --- | --- | --- |
| `SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`, `SPOTIFY_REDIRECT_URI` | empty | Your server's Spotify app. You can also set it up in the app. |
| `LASTFM_API_KEY`, `LASTFM_API_SECRET` | empty | Your server's Last.fm app, for play counts and scrobbling. |

## The VPN overlay [#the-vpn-overlay]

| Variable | Default | What it does |
| --- | --- | --- |
| `VPN_SERVICE_PROVIDER` | `protonvpn` | Your VPN, as Gluetun names it. |
| `WIREGUARD_PRIVATE_KEY` | none | Your WireGuard key. Required for the overlay. |
| `WIREGUARD_ADDRESSES` | `10.2.0.2/32` | Your WireGuard address. |
| `LAN_SUBNET` | `172.16.0.0/12` | Networks that skip the VPN, like your home network. |

See [Compose files](/docs/reference/compose/#route-downloads-through-a-vpn).

## The rest [#the-rest]

The compose file passes a few more, for acquisition's own sources and the VPN's exit addresses. Leave them empty
unless you know you need them.
