Skip to Content
ConfigurationEnvironment Variables

Environment Variables

Tracearr uses environment variables for core configuration.

Required Variables

VariableDescriptionExample
DATABASE_URLPostgreSQL/TimescaleDB connection stringpostgres://user:pass@host:5432/tracearr
REDIS_URLRedis connection stringredis://localhost:6379
JWT_SECRETSigning key for authentication tokens64-character hex string
COOKIE_SECRETCookie signing key64-character hex string

Optional Variables

VariableDescriptionDefault
PORTPort the server binds to inside the container3000
NODE_ENVEnvironment modeproduction
LOG_LEVELLogging verbosityinfo
BETTER_AUTH_SECRETSession signing/encryption keyderived from JWT_SECRET
TZTimezoneUTC
CORS_ORIGINAllowed CORS origin for API requestsreflects the request origin
TRUST_PROXYTrust X-Forwarded-* headers from a reverse proxyfalse
OIDC_ISSUER_URLOIDC issuer base URLnone
OIDC_CLIENT_IDOIDC client IDnone
OIDC_CLIENT_SECRETOIDC client secretnone
OIDC_PROVIDER_NAMELabel for the SSO login buttonSSO
REDIS_PREFIXRedis key prefix for namespacingno prefix
CLAIM_CODEClaim code for first time setupnone
BASE_PATHBase path when served under a subpathnone
DNS_CACHE_MAX_TTLDNS cache maximum TTL in secondsdisabled
GZIP_ENABLEDEnable server-side gzip compressionfalse
IMAGE_CACHE_MIN_FREE_PERCENTFree disk the poster cache leaves on its volume, in percent10
IMAGE_CACHE_MAX_MBHard ceiling on the poster cache size in MBnone
BACKUP_DIRDirectory for storing database backups/data/backup
ENCRYPTION_KEYKey for destination secrets and email link signaturesderived from JWT_SECRET

In the compose files, PORT sets the host side of the port mapping, "${PORT:-3000}:3000". The container always listens on 3000. To reach Tracearr on a different host port, set PORT=8080 in your .env and leave the container port alone. Setting PORT in the service’s environment: block moves the port the server binds to, which leaves the published mapping and the image’s health check pointing at 3000.

Database Configuration

Tracearr requires TimescaleDB (PostgreSQL with the TimescaleDB extension) for time-series data storage.

DATABASE_URL=postgres://tracearr:password@localhost:5432/tracearr

Redis Configuration

Redis is used for caching and background job queues.

REDIS_URL=redis://localhost:6379

For Redis with authentication:

REDIS_URL=redis://:password@localhost:6379

To enable Redis key prefixing:

Redis key prefixes must end with a delimiter (we recommend a colon ”:”) to ensure proper namespacing and avoid key collisions in shared Redis instances.

REDIS_PREFIX=myprefix:

Authentication Secrets

Tracearr requires two secrets, each a long random string unique to your installation (generate with openssl rand -hex 32):

  • JWT_SECRET signs authentication tokens, including tokens for mobile devices paired on older versions.
  • COOKIE_SECRET signs cookies.

A third secret, BETTER_AUTH_SECRET, signs and encrypts web and mobile sessions. It is optional: when unset, Tracearr derives it from JWT_SECRET (HKDF-SHA256), so existing installs need no new configuration. Setting it explicitly is recommended. Tracearr fails to start only when neither BETTER_AUTH_SECRET nor JWT_SECRET is set.

A fourth, ENCRYPTION_KEY, is 64 hex characters and also optional. It protects the stored configuration of every notification destination, including SMTP passwords and webhook URLs, and it signs the unsubscribe and browser-view links in newsletter email. Each of the two uses gets its own key derived from this value, so neither can open the other. When ENCRYPTION_KEY is unset both derive from JWT_SECRET by HKDF-SHA256 instead, and existing installs need no new configuration. Set it when you want to rotate JWT_SECRET without re-entering every destination secret.

JWT_SECRET=<64-character hex string> COOKIE_SECRET=<64-character hex string> BETTER_AUTH_SECRET=<64-character hex string> # optional, recommended ENCRYPTION_KEY=<64-character hex string> # optional

A malformed value stops the server on start:

ENCRYPTION_KEY is set but is not 64 hex characters; fix or unset it

Rotating JWT_SECRET while ENCRYPTION_KEY is unset leaves Tracearr unable to read the stored destination secrets. Each affected destination is flagged “Re-enter this destination’s secret” in the list, receives nothing until you do, and cannot be tested.

Rotating JWT_SECRET also changes the derived BETTER_AUTH_SECRET when it is not set explicitly, which invalidates all web sessions and paired mobile devices. If you run multiple Tracearr instances against the same database, every instance must share the same BETTER_AUTH_SECRET, or the same JWT_SECRET when relying on derivation.

OIDC Single Sign-On

Tracearr supports login through an OIDC identity provider (Authentik, Authelia, Keycloak, and similar). OIDC login is enabled only when all three of OIDC_ISSUER_URL, OIDC_CLIENT_ID, and OIDC_CLIENT_SECRET are set. The endpoint for the redirect URI is at /api/v1/auth/oauth2/callback/oidc.

OIDC_ISSUER_URL=https://auth.example.com OIDC_CLIENT_ID=tracearr OIDC_CLIENT_SECRET=<from your identity provider> OIDC_PROVIDER_NAME=Authentik # optional, defaults to "SSO"

When configured, the login page shows an SSO button labeled with OIDC_PROVIDER_NAME.

Reverse Proxy

Behind an HTTPS reverse proxy, logins work as long as the proxy preserves the Host header, forwards X-Forwarded-Host, or CORS_ORIGIN is set to the public URL. Forward X-Forwarded-Proto so session cookies carry the Secure attribute over HTTPS.

CORS_ORIGIN=https://tracearr.example.com TRUST_PROXY=true

When CORS_ORIGIN is unset, the API reflects the request origin. Set TRUST_PROXY=true so Tracearr resolves the real client IP from X-Forwarded-* headers; this makes sign-in rate limits count per client instead of per proxy.

Three API paths answer without a login by design, and an authenticating proxy such as Authelia, Authentik or a Cloudflare Access policy must let them through:

/api/v1/email/unsubscribe/* /api/v1/newsletters/view/* /api/v1/images/proxy

The first is the unsubscribe page every newsletter links to; the second is the browser view of a digest that was sent; the third serves hosted poster images to mail clients. Gating the first two shows members a login page instead of the page they asked for, and gating the third leaves hosted posters blank. The first two carry their own limit of 60 requests a minute.

Reverse proxies that rewrite the Host header must forward X-Forwarded-Host (or set CORS_ORIGIN to the public URL) for cookie login to work.

Claim Code

The CLAIM_CODE environment variable is used to protect the initial setup page.
This is recommended when Tracearr is exposed to the public internet.

When set, the claim code will be printed to the log on startup.

Claim code

Before you can access the setup page, you must enter the claim code.

Claim code

Base Path

Set BASE_PATH when you want Tracearr to be served under a subpath.
This ensures all routes, assets, and links are prefixed correctly.

BASE_PATH=/tracearr

You only need to set this if Tracearr is accessed through a reverse proxy under a subpath (e.g. https://example.com/tracearr). If Tracearr is served at the root, this can be left unset.

DNS Cache

Set DNS_CACHE_MAX_TTL to enable DNS caching for outgoing requests.
This can improve performance by reducing the number of DNS lookups for frequently accessed hosts.
DNS caching is disabled if DNS_CACHE_MAX_TTL is not set.

DNS_CACHE_MAX_TTL=3600

Tracearr will respect the TTL provided by the DNS server, but will not cache entries longer than the value set in DNS_CACHE_MAX_TTL. Error responses (e.g. DNS resolution failures) are not cached to ensure that transient issues do not persist longer than necessary.

Gzip Compression

Set GZIP_ENABLED=true to enable server-side gzip compression for HTTP responses.
This compresses static assets and API responses, reducing bandwidth usage.

GZIP_ENABLED=true

Most deployments sit behind a reverse proxy (e.g. Nginx, Caddy, Traefik) that already handles compression. Only enable this if Tracearr is serving traffic directly without a compressing proxy in front of it. \ Enabling gzip will slightly increase CPU usage on the server.

Poster Cache

Tracearr keeps one 360×540 copy of every poster under data/image-cache and keeps it until the poster changes or its item leaves the library. Nothing is evicted to make room. When free disk on that volume would fall under IMAGE_CACHE_MIN_FREE_PERCENT the cache stops growing, the precache pass reports disk-limited in Settings → General, and posters that are not cached are fetched from the media server on request. A library of 100k posters needs about 2 GB.

Backup Directory

Set BACKUP_DIR to customize where Tracearr stores database backups. The default location is /data/backup inside the container.

BACKUP_DIR=/custom/path/to/backups

When using Docker, the default /data/backup path is already configured as a volume. If you change this, ensure the directory exists and is writable, and mount it as a volume if needed.
See Backup & Restore for full documentation.

Last updated on