# Server configuration reference

> Every pushq server setting: YAML keys, PUSHQ_* environment variables, defaults, .env loading order, and all CLI commands and flags.

Source: https://pushqueue.dev/docs/self-hosting/configuration/

A pushq server reads its settings from four places. Later sources override earlier ones:

1. Built-in defaults.
2. A YAML config file, passed with `pushq serve -c pushq.yaml`.
3. Environment variables (`PUSHQ_*` and `WORKOS_*`), including ones loaded from a `.env` file.
4. Command-line flags (`--db`, `--listen`, `--log-level`).

Every setting has a default, so `pushq serve` with no config at all starts a working server on `:8080` with SQLite in `./pushq.db`.

## Load settings from a .env file

Before reading the config file, pushq loads environment variables from a `.env` file in the working directory. Set `PUSHQ_ENV_FILE` to load a different file instead.

- Variables that are already set in the real environment are left alone, so the real environment always wins over `.env`.
- A missing file is not an error.
- The format is `KEY=VALUE`, one per line. Blank lines, `#` comments, an `export ` prefix and matching single or double quotes around the value are allowed. Anything else is a startup error that names the line.

```bash
# .env
PUSHQ_DB=postgres://pushq:secret@localhost/pushq
PUSHQ_API_KEYS=admin:pq_admin_change-me
export PUSHQ_LOG_FORMAT="json"
```

`pushq serve`, `pushq migrate` and `pushq users` load `.env`. `pushq dev` ignores both `.env` and the config file and uses its own fixed settings.

Use this when you want to keep secrets such as `WORKOS_API_KEY` or a database password out of the YAML file.

## Configuration settings reference

Durations use Go syntax: `500ms`, `30s`, `15m`, `1h`, `168h`. There is no `d` unit, so write 7 days as `168h`. The YAML parser rejects unknown keys, so a typo fails at startup instead of being ignored.

### Database, listen address and API keys

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `db` | `PUSHQ_DB` | string | `sqlite:pushq.db` | Database URL: `sqlite:<path>` or `postgres://…` / `postgresql://…`. Anything else is rejected. Flag: `--db`. |
| `listen` | `PUSHQ_LISTEN` | string | `:8080` | Address the HTTP server listens on, e.g. `127.0.0.1:8080`. Flag: `--listen`. |
| `api_keys` | `PUSHQ_API_KEYS` | list | none | Config-file API keys. Each entry has a `key` and a `role` of `admin` or `writer`. In the environment variable, write comma-separated `role:key` pairs: `admin:pq_aaa,writer:pq_bbb`. Setting the variable replaces the YAML list. |

Config-file keys are optional; you can also create keys in the dashboard. An `admin` key can do everything, including listing and deleting queues and managing members and keys. A `writer` key can create and change queues, enqueue tasks, and read queues and tasks it knows by name, but can't list all queues or delete queues. See [API keys](https://pushqueue.dev/docs/guides/api-keys/) for creating keys in the dashboard.

:::caution
With no `api_keys` and no dashboard accounts, the server accepts unauthenticated requests until someone completes first-time setup. See [create the first admin account](https://pushqueue.dev/docs/self-hosting/install/#create-the-first-admin-account).
:::

### WorkOS settings (SaaS mode)

Setting both `client_id` and `api_key` turns on SaaS mode: WorkOS becomes the only sign-in, teams are WorkOS Organizations, and each team's data is isolated. Setting only one of the two is a startup error. See [SaaS mode](https://pushqueue.dev/docs/self-hosting/saas-mode/) for the full setup.

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `workos.client_id` | `WORKOS_CLIENT_ID` | string | empty | WorkOS client ID. |
| `workos.api_key` | `WORKOS_API_KEY` | string | empty | WorkOS API key. Prefer the environment variable over the YAML file. |
| `workos.redirect_uri` | `WORKOS_REDIRECT_URI` | string | `<request origin>/v1/auth/workos/callback` | Where WorkOS sends people back after GitHub sign-in. Must be listed under Redirects in the WorkOS dashboard. Set it when a proxy changes the host or scheme. |
| `workos.api_base` | `WORKOS_API_BASE` | string | `https://api.workos.com` | Overrides the WorkOS API URL. Only useful for tests. |

### Dispatcher and concurrency

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `dispatcher.global_concurrency` | `PUSHQ_GLOBAL_CONCURRENCY` | int | `512` | Maximum HTTP deliveries in flight across all queues on this server. Must be at least 1. |
| `dispatcher.per_queue_claim_cap` | `PUSHQ_PER_QUEUE_CLAIM_CAP` | int | `100` | Maximum tasks claimed from one queue in a single scheduling pass. Must be at least 1. |
| `dispatcher.reconcile_interval` | `PUSHQ_RECONCILE_INTERVAL` | duration | `30s` | How often the dispatcher re-reads which queues have due work and their settings from the database. |
| `dispatcher.drain_timeout` | `PUSHQ_DRAIN_TIMEOUT` | duration | `30s` | On shutdown, how long in-flight deliveries get to finish before they are cancelled. |
| `dispatcher.sweep_interval` | none | duration | `15s` | How often expired task leases are found and the tasks retried. |
| `dispatcher.cleanup_interval` | none | duration | `60s` | How often finished tasks past their retention are deleted. |
| `dispatcher.lease_grace` | none | duration | `60s` | Extra time added to a task's `dispatch_deadline_seconds` to form its lease. A task whose lease expires without a recorded result counts as a failed attempt (`lease_lost`) and is retried. |

### Request limits and dedup window

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `limits.max_body_bytes` | `PUSHQ_MAX_BODY_BYTES` | int | `1048576` (1 MiB) | Largest task body, after base64 decoding. Must be at least 1. |
| `limits.max_headers_bytes` | `PUSHQ_MAX_HEADERS_BYTES` | int | `16384` (16 KiB) | Largest total size of a task's custom headers (names plus values). |
| `limits.max_schedule_ahead` | `PUSHQ_MAX_SCHEDULE_AHEAD` | duration | `8760h` (1 year) | How far in the future a task may be scheduled. `0` turns the check off (`delay_seconds` is still capped at 100 years). |
| `limits.dedup_window` | `PUSHQ_DEDUP_WINDOW` | duration | `1h` | How long a `task_id` stays reserved after the task finishes or is deleted. Reusing it within the window returns `409 already_exists`. |

### Task retention

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `retention.succeeded` | `PUSHQ_RETENTION_SUCCEEDED` | duration | `24h` | How long succeeded tasks and their attempt history are kept. |
| `retention.failed` | `PUSHQ_RETENTION_FAILED` | duration | `168h` (7 days) | How long failed tasks and their attempt history are kept. |

A finished task is never deleted before `limits.dedup_window` has passed, even if its retention is shorter.

### Metrics

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `metrics.public` | `PUSHQ_METRICS_PUBLIC` | bool | `true` | Serve `GET /metrics` without authentication. When `false`, it needs an admin API key or a dashboard session (in SaaS mode, only a config-file key). In the variable, `1` or `true` (any case) means true; any other value means false. |

### Logging

| YAML key | Environment variable | Type | Default | Description |
|---|---|---|---|---|
| `log.level` | `PUSHQ_LOG_LEVEL` | string | `info` | `debug`, `info`, `warn` or `error`. Unknown values fall back to `info`. Flag: `--log-level`. |
| `log.format` | `PUSHQ_LOG_FORMAT` | string | `text` | `text` or `json`. Logs go to stderr. |

## Example pushq.yaml config file

The same configuration as a YAML file and as environment variables:


**YAML**

```yaml
# /etc/pushq/pushq.yaml

# sqlite:<path> for one node, postgres://… for several replicas.
db: sqlite:/var/lib/pushq/pushq.db
# db: postgres://pushq:secret@db.internal:5432/pushq?sslmode=require

# Bind to localhost and put a TLS-terminating proxy in front.
listen: 127.0.0.1:8080

# Optional config-file keys. You can also create keys in the dashboard.
api_keys:
  - { key: "pq_admin_change-me",  role: admin }   # everything
  - { key: "pq_writer_change-me", role: writer }  # queues and tasks by name

# SaaS mode. Leave out for a self-hosted server with local accounts.
# Prefer WORKOS_API_KEY in the environment over putting it here.
# workos:
#   client_id: client_01...
#   redirect_uri: https://pushq.example.com/v1/auth/workos/callback

dispatcher:
  global_concurrency: 512    # deliveries in flight, all queues together
  per_queue_claim_cap: 100   # tasks claimed per queue per scheduling pass
  reconcile_interval: 30s
  drain_timeout: 30s         # keep below your process manager's stop timeout
  sweep_interval: 15s
  cleanup_interval: 60s
  lease_grace: 60s

limits:
  max_body_bytes: 1048576    # 1 MiB
  max_headers_bytes: 16384   # 16 KiB
  max_schedule_ahead: 8760h  # 1 year; 0 = no limit
  dedup_window: 1h

retention:
  succeeded: 24h
  failed: 168h               # 7 days

metrics:
  public: true               # false = /metrics needs an admin key or a session

log:
  level: info                # debug | info | warn | error
  format: json               # text | json
```

**Environment**

```bash
PUSHQ_DB=sqlite:/var/lib/pushq/pushq.db
PUSHQ_LISTEN=127.0.0.1:8080
PUSHQ_API_KEYS=admin:pq_admin_change-me,writer:pq_writer_change-me
PUSHQ_GLOBAL_CONCURRENCY=512
PUSHQ_PER_QUEUE_CLAIM_CAP=100
PUSHQ_RECONCILE_INTERVAL=30s
PUSHQ_DRAIN_TIMEOUT=30s
PUSHQ_MAX_BODY_BYTES=1048576
PUSHQ_MAX_HEADERS_BYTES=16384
PUSHQ_MAX_SCHEDULE_AHEAD=8760h
PUSHQ_DEDUP_WINDOW=1h
PUSHQ_RETENTION_SUCCEEDED=24h
PUSHQ_RETENTION_FAILED=168h
PUSHQ_METRICS_PUBLIC=true
PUSHQ_LOG_LEVEL=info
PUSHQ_LOG_FORMAT=json
```

`dispatcher.sweep_interval`, `dispatcher.cleanup_interval` and `dispatcher.lease_grace` have no environment variables; set them in the YAML file.

## CLI commands and flags

Run `pushq <command> --help` for the built-in help.

### pushq serve

Runs the server: the API, the dashboard and the dispatcher. Applies database migrations on startup. Stops gracefully on `SIGINT` or `SIGTERM`.

| Flag | Description |
|---|---|
| `-c, --config <path>` | YAML config file. |
| `--db <url>` | Database URL. Overrides `db` and `PUSHQ_DB`. |
| `--listen <addr>` | Listen address. Overrides `listen` and `PUSHQ_LISTEN`. |
| `--log-level <level>` | `debug`, `info`, `warn` or `error`. Overrides `log.level` and `PUSHQ_LOG_LEVEL`. |

```bash
pushq serve -c /etc/pushq/pushq.yaml --log-level debug
```

### pushq dev

Runs a local development server: authentication disabled, SQLite in `<temp dir>/pushq-dev.db`, debug logs, and faster reconcile (1s), sweep (2s) and cleanup (5s) timers. It does not read a config file or `.env`.

| Flag | Default | Description |
|---|---|---|
| `--listen <addr>` | `:8080` | Listen address. |
| `--memory` | off | Use an in-memory database; all state is lost on exit. |

### pushq migrate

Applies database migrations and exits. `pushq serve` does this on its own, so you only need it to migrate ahead of a deploy.

| Flag | Description |
|---|---|
| `-c, --config <path>` | YAML config file. |
| `--db <url>` | Database URL. |

### pushq users

Manages dashboard accounts directly in the database, so it works when nobody can sign in. Takes `-c, --config` and `--db` like `migrate`.

| Command | Description |
|---|---|
| `pushq users list` | Lists accounts with email, name, role and last login. |
| `pushq users reset-password <email> [--url <public url>]` | Prints a one-time password-reset link. `--url` is the server's public URL used to build the link (default `http://localhost:8080`). |

### pushq openapi

Prints the OpenAPI document generated from the server's routes, the same one a running server serves at `/openapi.json`. Needs no database.

```bash
pushq openapi > openapi.json
```

### pushq version

Prints the version and commit, e.g. `pushq 1.0.0 (abc1234)`.

### pushq queues and pushq tasks

Client commands that call a running server's API. Both take:

| Flag | Default | Description |
|---|---|---|
| `--server <url>` | `$PUSHQ_SERVER`, else `http://localhost:8080` | Server URL. |
| `--api-key <key>` | `$PUSHQ_API_KEY` | API key sent as a bearer token. |

| Command | Description |
|---|---|
| `pushq queues ls [--prefix <p>]` | List queues (admin key). |
| `pushq queues upsert <name> [flags]` | Create or update a queue. Flags: `--rate`, `--burst`, `--concurrency`, `--max-attempts`, `--min-backoff`, `--max-backoff` (durations, e.g. `1s`, `5m`), `--base-url`, `--method`, `--signing-secret` (`""` clears it; omit to keep), `--dlq`. |
| `pushq queues get <name>` | Show a queue. |
| `pushq queues pause <name>` / `resume <name>` | Pause or resume dispatching. |
| `pushq queues purge <name>` | Delete all tasks created up to now. |
| `pushq queues rm <name>` | Delete a queue (admin key). |
| `pushq queues stats <name> [--id-prefix <p>]` | Queue depth and error rates. |
| `pushq tasks ls <queue> [--state <s>] [--prefix <p>] [--view basic\|full]` | List tasks. `--state` is `pending`, `running`, `succeeded` or `failed`. |
| `pushq tasks create <queue> [flags]` | Enqueue a task. Flags: `--id`, `--url`, `--path`, `--method`, `--json`, `--delay` (e.g. `30s`, `2h`), `--max-attempts`. |
| `pushq tasks get <queue> <id>` | Show a task, including headers and body. |
| `pushq tasks rm <queue> <id>` | Delete a task. |
| `pushq tasks run <queue> <id>` | Dispatch a task now. |
| `pushq tasks attempts <queue> <id>` | Show a task's attempt history. |

```bash
export PUSHQ_SERVER=https://pushq.example.com PUSHQ_API_KEY=pq_admin_change-me
pushq queues upsert emails --rate 10 --max-attempts 5 --base-url https://app.example.com
pushq tasks create emails --path /hooks/send --json '{"to":"a@example.com"}' --delay 1h
pushq queues stats emails
```
