Skip to main content
n8n is configured primarily through environment variables, allowing flexible deployment across different environments. This guide covers all major configuration options.

Core Configuration

Instance Settings

string
required
Encryption key for securing credentials in the database.
  • Minimum 10 characters
  • Generate with: openssl rand -base64 32
  • Never change after initial setup or credentials become unrecoverable
  • Back up securely in a password manager or secrets vault
string
default:"~/.n8n"
Path to n8n’s data folder containing database, settings, and custom extensions.
string
default:"localhost"
Hostname or domain where n8n is accessible.
number
default:"5678"
Port for the n8n web server.
string
default:"http"
Protocol (http or https) used to access n8n.
string
Full URL where webhooks can reach n8n. Defaults to {N8N_PROTOCOL}://{N8N_HOST}/.

Timezone

string
default:"America/New_York"
Default timezone for n8n workflows (used by Schedule node).
string
System timezone for the container/process.

Database Configuration

Database Type

string
default:"sqlite"
Database type: sqlite or postgresdb.
PostgreSQL is required for:
  • Queue mode (scaling)
  • Multi-main setup
  • Production deployments

SQLite Configuration

string
default:"database.sqlite"
SQLite database filename (relative to N8N_USER_FOLDER).
number
default:"3"
SQLite connection pool size (minimum 1).
boolean
default:"false"
Run VACUUM on startup to optimize database. Warning: Increases startup time.

PostgreSQL Configuration

string
default:"localhost"
PostgreSQL server hostname.
number
default:"5432"
PostgreSQL server port.
string
default:"n8n"
PostgreSQL database name.
string
default:"postgres"
PostgreSQL username.
string
PostgreSQL password.
Can also use DB_POSTGRESDB_PASSWORD_FILE to read from a file (Docker secrets).
string
default:"public"
PostgreSQL schema name.
number
default:"2"
PostgreSQL connection pool size.
number
default:"20000"
Connection timeout in milliseconds.
number
default:"300000"
Query execution timeout in milliseconds. Set to 0 to disable.

PostgreSQL SSL

boolean
default:"false"
Enable SSL/TLS for PostgreSQL connections.
string
Path to SSL certificate authority file.
string
Path to SSL client certificate.
string
Path to SSL client key.
boolean
default:"true"
Reject unauthorized SSL connections.

Database Logging

boolean
default:"false"
Enable database query logging.
string
default:"error"
Logging level: query, error, schema, warn, info, log, or all.
number
default:"0"
Log only queries exceeding this time (ms). Set to 0 to disable.

Queue Mode Configuration

Execution Mode

string
default:"regular"
Execution mode: regular (in-process) or queue (worker-based).
Queue mode requires PostgreSQL and Redis.

Redis Configuration

string
default:"localhost"
Redis server hostname.
number
default:"6379"
Redis server port.
number
default:"0"
Redis database number.
string
Redis username (Redis 6.0+).
string
Redis password.
number
default:"10000"
Max cumulative timeout (ms) for Redis connection retries before exit.
string
default:"bull"
Prefix for Bull queue keys in Redis.

Redis TLS

boolean
default:"false"
Enable TLS for Redis connections.
string
default:"LOOKUP"
DNS resolution strategy: LOOKUP (use DNS) or NONE (pass hostnames directly).
Use NONE for AWS ElastiCache with TLS to avoid certificate errors.

Redis Cluster

string
Comma-separated list of Redis cluster nodes as host:port pairs.

Worker Settings

boolean
default:"false"
Enable health check endpoints for workers.
number
default:"5678"
Port for worker health check server.
number
default:"60000"
Lease duration (ms) for a worker processing a job.
number
default:"10000"
How often (ms) a worker must renew its lease.
number
default:"30000"
How often (ms) to check for stalled jobs. Set to 0 to disable.

Execution Settings

number
default:"-1"
Workflow execution timeout in seconds. -1 for unlimited.
number
default:"3600"
Maximum allowed execution timeout in seconds.
number
default:"-1"
Max concurrent production executions. -1 for unlimited.

Execution Data Pruning

boolean
default:"true"
Enable automatic deletion of old execution data.
number
default:"336"
Age in hours before executions are eligible for soft deletion.
number
default:"10000"
Maximum number of executions to keep. 0 for unlimited.
number
default:"1"
Hours buffer before hard-deleting executions.

Task Runner Configuration

string
default:"internal"
Task runner mode: internal (child process) or external (separate process).
number
default:"5679"
Port for task runner broker.
string
default:"127.0.0.1"
IP address for task runner broker to listen on.
string
Authentication token for task runners.
string
URI for runners to connect to broker (runner-side config).
number
default:"10"
Max concurrent tasks per runner.
number
default:"300"
Task execution timeout in seconds.
number
default:"1073741824"
Maximum payload size in bytes (default 1GB).

Security Configuration

string
default:"~/.n8n-files"
Directories that ReadWriteFile and ReadBinaryFiles nodes can access. Separate with ;.
Set to empty string to disable restrictions (insecure for production).
boolean
default:"true"
Block access to n8n’s internal directories.
string
JSON array of node types to exclude for security.
string
default:"[]"
JSON array of node types to include. Empty means all (except excluded).

Multi-Main Setup

boolean
default:"false"
Enable multi-main setup for high availability (requires Enterprise license).
number
default:"10"
Leader key TTL in seconds.
number
default:"3"
Leader check interval in seconds.

Monitoring & Metrics

boolean
default:"false"
Enable Prometheus metrics endpoint at /metrics.
string
default:"n8n_"
Prefix for Prometheus metric names.
boolean
default:"true"
Include Node.js and system metrics.
boolean
default:"false"
Include workflow ID label on metrics (increases cardinality).

User Management

string
JWT secret for session tokens. Auto-generated if not set.
number
default:"168"
JWT session duration in hours (default 7 days).

Email Configuration

string
default:"smtp"
Email sending mode: smtp or empty to disable.
string
SMTP server hostname.
number
default:"465"
SMTP server port.
string
SMTP username.
string
SMTP password.
boolean
default:"true"
Use SSL for SMTP.
string
Sender name and email.

Public API

boolean
default:"false"
Disable the Public API.
string
default:"api"
Path segment for Public API.

Endpoints

string
default:"webhook"
Path segment for webhook endpoints.
string
default:"rest"
Path segment for REST API.
string
default:"/healthz"
Health check endpoint path.
boolean
default:"false"
Disable the web UI (API-only mode).

Configuration Examples

Environment Variable Files

For Docker secrets and Kubernetes:
When using _FILE variants, n8n reads the value from the specified file path instead of the environment variable directly.

Next Steps

Docker Deployment

See these configurations in Docker Compose examples

Scaling

Learn about queue mode and scaling strategies