# Environment variables

> Every setting the Social Crawl API, the web app, Docker Compose and this docs site read, with its default, its limits and what it does.

Source: https://crawl-docs.pdhq.win/advanced/environment-variables/
Last updated: 2026-12-02

The API checks its environment when it starts (`apps/api/src/config/env.ts`, a `zod` schema) and refuses to start, saying which value is wrong. Values are cleaned first: surrounding spaces and quotes are removed, because environment panels and copy and paste often add them.

In Dokploy set them under **Environment**. With plain Docker put them in a `.env` file next to `docker-compose.yml`. `.env.example` in the repository lists the common ones with comments.

## Needed to start

| Variable | Default | Meaning |
| --- | --- | --- |
| `JWT_SECRET` | none, **required** | Signs logins and encrypts the saved WebDAV password. At least 32 characters. `openssl rand -base64 48`. Changing it ends every login and makes the saved WebDAV password unreadable. |
| `ADMIN_PASSWORD_HASH` | none, **required** | Your password as `scrypt:<salt>:<hash>`, 120 characters. See [Install the server](https://crawl-docs.pdhq.win/guide/install-the-server.md). |
| `DATABASE_URL` | In Compose: the stack's own `db` service | A PostgreSQL address. In Compose it is built from `POSTGRES_USER`, `POSTGRES_PASSWORD` and `POSTGRES_DB`. The API refuses an address that points at `sc-db` with an empty password. |

## Database (Compose)

| Variable | Default | Meaning |
| --- | --- | --- |
| `POSTGRES_PASSWORD` | empty | The stack's own database password. Letters and numbers only. Needed while the stack uses its own database, and once on a brand-new install even when `DATABASE_URL` is set. |
| `POSTGRES_USER` | `socialcrawl` | User of the stack's database. |
| `POSTGRES_DB` | `socialcrawl` | Name of the stack's database. |
| `DB_SYNCHRONIZE` | `false` in the API, `true` in Compose | Lets TypeORM create and alter tables at start. There are no migrations. See [Data model](https://crawl-docs.pdhq.win/advanced/data-model.md). |
| `MIGRATE_TO_DATABASE_URL` | unset | A second address that Settings → Database copies into. Read only when you press Check or Copy. Remove it afterwards. |
| `OLD_DATABASE_URL` | unset | The address of the database you left, for Settings → Database to delete its data. Remove it afterwards. |

## Server

| Variable | Default | Meaning |
| --- | --- | --- |
| `PORT` | `4000` | The API's port. |
| `CORS_ORIGINS` | empty | Origins allowed to call the API from a browser, comma separated. The extension uses its own origin. |
| `RESTRICTED_PASSWORD_HASH` | unset | Second password for the restricted part, same format as `ADMIN_PASSWORD_HASH`. Without it the part cannot be opened. |
| `EXTENSION_DIR` | `../extension/dist` | The built extension offered in Settings. In the Docker image it is built in. |
| `LAB_ENABLED` | off | Turns on the `/lab` routes (testing only; they can write 12 GB per test to WebDAV). Leave off. |

## Storage

| Variable | Default | Meaning |
| --- | --- | --- |
| `STORAGE_DRIVER` | `local` | `local` or `s3`. |
| `STORAGE_DIR` | `./storage` (`/data/bundles` in Compose) | Where bundles live with the `local` driver. |
| `S3_ENDPOINT` | none | Required with `s3`. Must start with `https://`. For R2: `https://<account id>.r2.cloudflarestorage.com`. |
| `S3_BUCKET` | none | Required with `s3`. |
| `S3_REGION` | `auto` | Region. |
| `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY` | none | Required with `s3`. |

## Videos

| Variable | Default | Meaning |
| --- | --- | --- |
| `MAX_VIDEO_MB` | `4096` (1 to 5000) | The largest video the extension may send. Settings → Videos overrides it. While a post is saved the server needs about twice this free on its temp disk. |
| `UPLOAD_DIR` | the system's temp folder | Where uploaded videos wait until their post is saved. |
| `VIDEO_CACHE_MB` | `2048` (`0` = off, up to 1,000,000) | How much of the videos kept on WebDAV the server holds on its disk. |
| `VIDEO_CACHE_DIR` | the system's temp folder | Where those parts are kept. |

## Speech recognition

All optional. See [Captions and transcripts](https://crawl-docs.pdhq.win/guide/captions-and-transcripts.md).

| Variable | Default | Meaning |
| --- | --- | --- |
| `API_TARGET` | `runtime` | Compose build target. `runtime-speech` builds the image with Whisper (about 3 GB). |
| `SPEECH_MODEL_NAME` | `base` | Which model the speech image carries (`base`, `small`, ...). |
| `SPEECH_COMMAND` | unset (set for you with `runtime-speech`) | The program that listens. Both this and `SPEECH_MODEL` are needed. |
| `SPEECH_MODEL` | unset (set for you with `runtime-speech`) | The model file. |
| `SPEECH_THREADS` | `4` in the API, `2` in Compose (1 to 64) | Processor threads it uses. |
| `SPEECH_LANGUAGE` | `auto` | `auto` or a code such as `en`. |
| `SPEECH_MAX_MINUTES` | `240` (1 to 1440) | The longest video or sound it listens to. |

## The web app

| Variable | Default | Meaning |
| --- | --- | --- |
| `API_URL` | `http://127.0.0.1:4000` (`http://sc-api:4000` in Compose) | Where the web app reaches the API from the server side. Never exposed to the browser. |

## Save YouTube from a link (experiment)

Optional, and not tested against the real YouTube. All are environment variables of the API; an empty one means "not set". Defaults in parentheses.

| Variable | Meaning |
| --- | --- |
| `YT_LINK` | `off` turns the whole experiment off. Its routes then answer 404. |
| `YTS_MAX_HEIGHT` (2160) | Tallest picture it takes, 144 to 4320. |
| `YTS_CODEC_ORDER` (`avc1,av01,vp09`) | The most wanted picture codec first. |
| `YTS_YT_PROXY` | `host:port` of an HTTP proxy used for YouTube only. `YTS_WARP_ROTATE=1` asks for a new address when blocked. |
| `YTS_SLICE_MB` (5), `YTS_PIECE_MB` (8), `YTS_PART_MB` (256), `YTS_PARALLEL` (2) | Read slice, upload piece, big-video part, slices read side by side. |
| `YTS_SLICE_TRIES` (4), `YTS_PART_TRIES` (3) | Retries per slice and per part. |
| `YTS_SMALL_MB` (0) | Videos up to this size go the normal way. 0 means the server's own limit. |
| `YTS_DOCTOR_EVERY_HOURS` (24; 0 = off), `YTS_DOCTOR_VIDEOS` | The daily self-check. |
| `YTS_CLIENTS_FILE`, `YTS_STREAM_UA`, `YTS_STATE_DIR` | A JSON copy of the clients table, the user agent for stream requests, and where its files are kept. |

## This docs site

Read when the docs are built (see [Maintain these docs](https://crawl-docs.pdhq.win/advanced/maintain-these-docs.md)).

| Variable | Default | Meaning |
| --- | --- | --- |
| `DOCS_SITE_URL` | `https://docs.example.com` | The public address of the docs. Used in `llms.txt`, the sitemap, `robots.txt`, canonical addresses and Open Graph tags. Set it to your real address. |
| `NEXT_PUBLIC_DOCS_APP_URL` | unset | The address of your app. When set, an **Open the app** button appears in the docs header. |
