Skip to content
Get started
Get started

bunqueue Environment Variables Reference

server · environment

Every environment variable, one page.

The complete environment variable reference for bunqueue: server ports, SQLite path, auth tokens, TLS, S3 backup, timeouts, rate limiting, and logging, each with type, default, and a runnable example.

TCP server port for client connections.

TypeDefaultExample
number67896789
Terminal window
TCP_PORT=6789 bunqueue start

HTTP server port for REST API and metrics.

TypeDefaultExample
number67906790
Terminal window
HTTP_PORT=6790 bunqueue start

Hostname to bind servers to.

TypeDefaultExample
string0.0.0.0127.0.0.1
Terminal window
# Bind to localhost only
HOST=127.0.0.1 bunqueue start
# Bind to all interfaces (default)
HOST=0.0.0.0 bunqueue start

Reserved. The variable is accepted and shown in the startup banner, but the TCP listener currently always binds HOST:TCP_PORT, it is not applied.

TypeDefaultExample
string(none)/var/run/bunqueue.sock

Unix socket path for the HTTP server (alternative to HTTP_PORT). When set, the HTTP server binds the Unix socket instead of a TCP port.

TypeDefaultExample
string(none)/var/run/bunqueue-http.sock
Terminal window
HTTP_SOCKET_PATH=/var/run/bunqueue-http.sock bunqueue start

Path to a PEM certificate file. Together with TLS_KEY_FILE, enables native TLS on both the TCP and HTTP servers. Setting only one of the two is a startup error (fail fast, never silent plaintext).

TypeDefaultExample
string(none)/etc/bunqueue/cert.pem
Terminal window
TLS_CERT_FILE=./cert.pem TLS_KEY_FILE=./key.pem bunqueue start

Path to the PEM private key file matching TLS_CERT_FILE.

TypeDefaultExample
string(none)/etc/bunqueue/key.pem

See the TLS guide for client options and self-signed setup.

Path to SQLite database file. When none of the variables is set, the server runs in-memory (no persistence).

Four aliases are read, in priority order: BUNQUEUE_DATA_PATH > BQ_DATA_PATH > DATA_PATH > SQLITE_PATH.

TypeDefaultExample
stringin-memory/var/lib/queue.db
Terminal window
BUNQUEUE_DATA_PATH=/var/lib/queue.db bunqueue start
# equivalent (lower-priority alias):
DATA_PATH=/var/lib/queue.db bunqueue start

Comma-separated list of authentication tokens.

TypeDefaultExample
string(none)token1,token2,token3
Terminal window
AUTH_TOKENS=secret-token-1,secret-token-2 bunqueue start

When set, all TCP and HTTP requests must include a valid token:

Terminal window
# TCP client
bunqueue push emails '{"to":"test@example.com"}' --token secret-token-1
# HTTP API
curl -H "Authorization: Bearer secret-token-1" http://localhost:6790/queues

CLI auth token for client commands. Avoids repeating --token on every command.

VariableTypeDefault
BQ_TOKENstring(none)
BUNQUEUE_TOKENstring(none)

Priority: --token flag > BQ_TOKEN > BUNQUEUE_TOKEN.

Terminal window
export BQ_TOKEN=secret-token-1
bunqueue stats # no --token needed
bunqueue push emails '{}' # uses BQ_TOKEN automatically

Minimum log level to output.

TypeDefaultValues
stringinfodebug, info, warn, error
Terminal window
LOG_LEVEL=debug bunqueue start

Log output format.

TypeDefaultValues
stringtexttext, json
Terminal window
LOG_FORMAT=json bunqueue start

JSON format output:

{"level":"info","msg":"Server started","tcp":6789,"http":6790,"ts":"2024-01-15T10:30:00Z"}

Enable automated S3 backups.

TypeDefaultValues
booleanfalse0, 1, false, true
Terminal window
S3_BACKUP_ENABLED=1 bunqueue start

S3 access key for authentication.

TypeDefaultAliases
string(none)AWS_ACCESS_KEY_ID
Terminal window
S3_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE bunqueue start

S3 secret key for authentication.

TypeDefaultAliases
string(none)AWS_SECRET_ACCESS_KEY
Terminal window
S3_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY bunqueue start

S3 bucket name for backups.

TypeDefaultAliases
string(none)AWS_BUCKET
Terminal window
S3_BUCKET=my-bunqueue-backups bunqueue start

AWS region for S3 bucket.

TypeDefaultAliases
stringus-east-1AWS_REGION
Terminal window
S3_REGION=eu-west-1 bunqueue start

Custom S3 endpoint for non-AWS providers. AWS_ENDPOINT is accepted as an alias, matching the other S3 variables.

TypeDefaultExample
string(none)https://account.r2.cloudflarestorage.com
Terminal window
# Cloudflare R2
S3_ENDPOINT=https://abc123.r2.cloudflarestorage.com bunqueue start
# MinIO
S3_ENDPOINT=http://localhost:9000 bunqueue start
# DigitalOcean Spaces
S3_ENDPOINT=https://nyc3.digitaloceanspaces.com bunqueue start

Interval between automated backups (milliseconds).

TypeDefaultExample
number21600000 (6 hours)3600000 (1 hour)
Terminal window
S3_BACKUP_INTERVAL=3600000 bunqueue start

Number of backups to keep.

TypeDefaultExample
number730
Terminal window
S3_BACKUP_RETENTION=30 bunqueue start

Prefix for backup files in S3.

TypeDefaultExample
stringbackups/bunqueue/prod/
Terminal window
S3_BACKUP_PREFIX=bunqueue/production/ bunqueue start

Timeout for graceful shutdown in milliseconds.

TypeDefaultExample
number3000060000
Terminal window
SHUTDOWN_TIMEOUT_MS=60000 bunqueue start

Interval for stats logging in milliseconds.

TypeDefaultExample
number300000 (5 min)60000
Terminal window
STATS_INTERVAL_MS=60000 bunqueue start

Default timeout for job processing in milliseconds.

TypeDefaultExample
number3000060000
Terminal window
WORKER_TIMEOUT_MS=60000 bunqueue start

Timeout for acquiring internal locks in milliseconds.

TypeDefaultExample
number500010000
Terminal window
LOCK_TIMEOUT_MS=10000 bunqueue start

Interval for cleaning up inactive worker registrations.

TypeDefaultExample
number60000120000
Terminal window
WORKER_CLEANUP_INTERVAL_MS=120000 bunqueue start

Slowloris mitigation on the TCP server: a connection that starts a frame but makes no progress completing it within this window is closed. Idle connections with no partial frame are never affected. 0 disables the timeout.

TypeDefaultExample
number60000120000
Terminal window
TCP_IDLE_TIMEOUT_MS=120000 bunqueue start

Maximum bytes buffered in a TCP connection’s outbound write queue before the connection is dropped (protects against clients that stop reading). 0 disables the bound.

TypeDefaultExample
number67108864 (64 MB)16777216
Terminal window
TCP_MAX_WRITE_QUEUE_BYTES=16777216 bunqueue start

Maximum retry attempts for webhook deliveries.

TypeDefaultExample
number35
Terminal window
WEBHOOK_MAX_RETRIES=5 bunqueue start

Delay between webhook retry attempts in milliseconds.

TypeDefaultExample
number10005000
Terminal window
WEBHOOK_RETRY_DELAY_MS=5000 bunqueue start

Maximum requests per client (TCP connection or HTTP client IP) within the rate limit window.

TypeDefaultExample
number100001000
Terminal window
RATE_LIMIT_MAX_REQUESTS=1000 bunqueue start

Time window for rate limiting in milliseconds.

TypeDefaultExample
number6000030000
Terminal window
RATE_LIMIT_WINDOW_MS=30000 bunqueue start

Interval for cleaning up rate limit tracking data.

TypeDefaultExample
number60000120000
Terminal window
RATE_LIMIT_CLEANUP_MS=120000 bunqueue start

These control the real-time monitoring events (queue:idle, queue:threshold, worker:overloaded, server:memory-warning, storage:size-warning) delivered over WebSocket/SSE. See the HTTP API events reference.

VariableDefaultDescription
QUEUE_IDLE_THRESHOLD_MS30000Emit queue:idle when a queue is empty with no active jobs for this long. 0 disables.
QUEUE_SIZE_THRESHOLD0 (disabled)Emit queue:threshold when a queue’s waiting count reaches this size.
WORKER_OVERLOAD_THRESHOLD_MS30000Emit worker:overloaded when a worker stays at max concurrency for this long.
MEMORY_WARNING_MB0 (disabled)Emit server:memory-warning when heap usage exceeds this many MB.
STORAGE_WARNING_MB0 (disabled)Emit storage:size-warning when the SQLite database exceeds this many MB.

Telemetry agent for the bunqueue Cloud dashboard. Cloud mode activates only when BUNQUEUE_CLOUD_URL, BUNQUEUE_CLOUD_API_KEY, and BUNQUEUE_CLOUD_INSTANCE_ID are all set.

VariableDefaultDescription
BUNQUEUE_CLOUD_URL(none)Cloud dashboard URL. Required for cloud mode.
BUNQUEUE_CLOUD_API_KEY(none)API key. Required for cloud mode.
BUNQUEUE_CLOUD_INSTANCE_ID(none)Unique instance identifier. Required for cloud mode.
BUNQUEUE_CLOUD_INSTANCE_NAMEhostnameDisplay name for this instance.
BUNQUEUE_CLOUD_SIGNING_SECRET(none)HMAC signing secret for payloads.
BUNQUEUE_CLOUD_INTERVAL_MS15000Snapshot upload interval in ms.
BUNQUEUE_CLOUD_INCLUDE_JOB_DATAtrueInclude job payloads in telemetry. Set false to send metadata only.
BUNQUEUE_CLOUD_REDACT_FIELDS(none)Comma-separated payload fields to redact.
BUNQUEUE_CLOUD_EVENTS(all)Comma-separated event filter.
BUNQUEUE_CLOUD_BUFFER_SIZE720Snapshot buffer size while offline.
BUNQUEUE_CLOUD_CIRCUIT_BREAKER_THRESHOLD5Consecutive failures before the circuit breaker opens.
BUNQUEUE_CLOUD_CIRCUIT_BREAKER_RESET_MS60000Circuit breaker reset window in ms.
BUNQUEUE_CLOUD_USE_WEBSOCKETtrueStream via WebSocket. Set false to disable.
BUNQUEUE_CLOUD_USE_HTTPtrueUpload via HTTP. Set false to disable.
BUNQUEUE_CLOUD_REMOTE_COMMANDStrueAllow remote commands from the dashboard. Set false to disable.

Require authentication for the /prometheus metrics endpoint. Only the literal value true enables it. The JSON /metrics endpoint is already covered by the general AUTH_TOKENS check.

TypeDefaultValues
booleanfalsetrue, false
Terminal window
METRICS_AUTH=true bunqueue start

Comma-separated list of allowed CORS origins.

TypeDefaultExample
string(none)https://app.example.com
Terminal window
CORS_ALLOW_ORIGIN=https://app.example.com,https://admin.example.com bunqueue start

Connection mode for the MCP server (bunqueue-mcp).

TypeDefaultValues
stringembeddedembedded, tcp
Terminal window
BUNQUEUE_MODE=tcp bunx bunqueue-mcp

Server host for the MCP server in TCP mode. The CLI also reads it as a fallback for --host (priority: HOST > BUNQUEUE_HOST > BQ_HOST).

TypeDefaultExample
stringlocalhostyour-server.com
Terminal window
BUNQUEUE_MODE=tcp BUNQUEUE_HOST=your-server.com bunx bunqueue-mcp

Server port for the MCP server in TCP mode. It also reads BUNQUEUE_TOKEN for authentication.

TypeDefaultExample
number67897000
Terminal window
BUNQUEUE_MODE=tcp BUNQUEUE_PORT=7000 bunx bunqueue-mcp

Connection pool size for the MCP server in TCP mode.

TypeDefaultExample
number24
Terminal window
BUNQUEUE_MODE=tcp BUNQUEUE_POOL_SIZE=4 bunx bunqueue-mcp

TCP_PORT / BUNQUEUE_TCP_PORT / BQ_TCP_PORT (CLI)

Section titled “TCP_PORT / BUNQUEUE_TCP_PORT / BQ_TCP_PORT (CLI)”

Fallback for the CLI --port flag when it is not passed explicitly. Read in priority order: TCP_PORT > BUNQUEUE_TCP_PORT > BQ_TCP_PORT. Using TCP_PORT means the same variable that binds the server also routes the client in the same shell.

Terminal window
export TCP_PORT=7000
bunqueue stats # connects to localhost:7000

Force embedded mode for client library.

TypeDefaultValues
string(none)1
Terminal window
BUNQUEUE_EMBEDDED=1 bun run worker.ts

Legacy alias for the data path, lowest priority (BUNQUEUE_DATA_PATH > BQ_DATA_PATH > DATA_PATH > SQLITE_PATH).

TypeDefaultExample
string(none)./data/queue.db
Terminal window
SQLITE_PATH=./data/queue.db bunqueue start

Disable colored output in CLI.

TypeDefaultValues
string(none)1
Terminal window
NO_COLOR=1 bunqueue stats
.env.development
TCP_PORT=6789
HTTP_PORT=6790
DATA_PATH=./data/dev.db
LOG_LEVEL=debug
LOG_FORMAT=text
.env.production
TCP_PORT=6789
HTTP_PORT=6790
DATA_PATH=/var/lib/production.db
LOG_LEVEL=info
LOG_FORMAT=json
AUTH_TOKENS=prod-token-abc123,prod-token-xyz789
# S3 Backup
S3_BACKUP_ENABLED=1
S3_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
S3_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
S3_BUCKET=company-bunqueue-backups
S3_REGION=us-east-1
S3_BACKUP_INTERVAL=3600000
S3_BACKUP_RETENTION=30
S3_BACKUP_PREFIX=production/
version: '3.8'
services:
bunqueue:
image: bunqueue:latest
ports:
- "6789:6789"
- "6790:6790"
volumes:
- bunqueue-data:/data
environment:
- TCP_PORT=6789
- HTTP_PORT=6790
- DATA_PATH=/data/queue.db
- LOG_LEVEL=info
- LOG_FORMAT=json
- AUTH_TOKENS=${AUTH_TOKENS}
- S3_BACKUP_ENABLED=1
- S3_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID}
- S3_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY}
- S3_BUCKET=${S3_BUCKET}
- S3_REGION=${S3_REGION}
- S3_BACKUP_INTERVAL=21600000
- S3_BACKUP_RETENTION=7
volumes:
bunqueue-data:
apiVersion: v1
kind: ConfigMap
metadata:
name: bunqueue-config
data:
TCP_PORT: "6789"
HTTP_PORT: "6790"
DATA_PATH: "/data/queue.db"
LOG_LEVEL: "info"
LOG_FORMAT: "json"
S3_BACKUP_ENABLED: "1"
S3_REGION: "us-east-1"
S3_BACKUP_INTERVAL: "21600000"
S3_BACKUP_RETENTION: "7"
S3_BACKUP_PREFIX: "kubernetes/"
---
apiVersion: v1
kind: Secret
metadata:
name: bunqueue-secrets
type: Opaque
stringData:
AUTH_TOKENS: "your-production-token"
S3_ACCESS_KEY_ID: "your-access-key"
S3_SECRET_ACCESS_KEY: "your-secret-key"
S3_BUCKET: "your-bucket"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bunqueue
spec:
replicas: 1
selector:
matchLabels:
app: bunqueue
template:
metadata:
labels:
app: bunqueue
spec:
containers:
- name: bunqueue
image: bunqueue:latest
ports:
- containerPort: 6789
- containerPort: 6790
envFrom:
- configMapRef:
name: bunqueue-config
- secretRef:
name: bunqueue-secrets
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: bunqueue-pvc

Environment variables take precedence in this order:

  1. Command-line arguments (highest)
  2. Configuration file
  3. Environment variables
  4. Default values (lowest)
Terminal window
# Command-line wins
TCP_PORT=6789 bunqueue start --tcp-port 7000
# Uses port 7000