Backend Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The backend configuration system in n8n provides a centralized and flexible way to manage the application's settings. It is primarily driven by environment variables, allowing for easy deployment and management across different environments (development, staging, production). The system is built around a main GlobalConfig class that aggregates various specialized configuration modules, each responsible for a specific domain like database connections, security, or execution behavior.
This modular approach, using decorators like @Env and @Nested, allows developers to define configuration options declaratively. Each option is mapped to a specific environment variable, with support for type validation, and default values. This ensures that the application is configured correctly and consistently upon startup.
Core Configuration Architecture
The configuration system is orchestrated from packages/@n8n/config/src/index.ts. The central piece is the GlobalConfig class, which acts as a container for all other configuration modules.
GlobalConfig Class
The GlobalConfig class uses the @Config decorator and aggregates different configuration modules using the @Nested decorator. Primitive configuration values are defined directly within the class using the @Env decorator, which maps the class property to an environment variable.
This diagram illustrates the composition of the GlobalConfig class, showing how it nests various specific configuration objects.
Top-Level Configuration
These are general settings for the n8n instance, configured directly on the GlobalConfig class.
| Property | Environment Variable | Type | Default | Description |
|---|---|---|---|---|
path | N8N_PATH | string | / | Path n8n is deployed to. |
host | N8N_HOST | string | localhost | Host name n8n can be reached at. |
port | N8N_PORT | number | 5678 | HTTP port n8n can be reached at. |
listen_address | N8N_LISTEN_ADDRESS | string | :: | IP address n8n should listen on. |
protocol | N8N_PROTOCOL | string | http | HTTP Protocol (http or https) |
editorBaseUrl | N8N_EDITOR_BASE_URL | string | '' | Public URL where the editor is accessible. |
proxy_hops | N8N_PROXY_HOPS | number | 0 | Number of reverse proxies n8n is running behind. |
Sources: packages/@n8n/config/src/index.ts:107-130, packages/@n8n/config/src/index.ts:184-186
Configuration Modules
The configuration is broken down into logical modules, each handling a specific aspect of the application.
Database Configuration
Managed by the DatabaseConfig class, these settings control the connection to the n8n database.
| Property | Environment Variable | Type | Default | Description |
|---|---|---|---|---|
type | DB_TYPE | string | sqlite | The type of database to use (e.g., postgresdb, mysqldb, sqlite). |
host | DB_POSTGRESDB_HOST / DB_MYSQLDB_HOST | string | localhost | The database host. |
port | DB_POSTGRESDB_PORT / DB_MYSQLDB_PORT | number | 5432 / 3306 | The database port. |
database | DB_POSTGRESDB_DATABASE / DB_MYSQLDB_DATABASE | string | n8n | The name of the database. |
user | DB_POSTGRESDB_USER / DB_MYSQLDB_USER | string | n8n | The database user. |
password | DB_POSTGRESDB_PASSWORD / DB_MYSQLDB_PASSWORD | string | n8n | The password for the database user. |
schema | DB_POSTGRESDB_SCHEMA | string | public | The database schema to use (Postgres only). |
ssl_rejectUnauthorized | DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED | boolean | true | Whether to reject self-signed SSL certificates. |
ssl_ca | DB_POSTGRESDB_SSL_CA | string | '' | Path to the SSL CA certificate. |
ssl_cert | DB_POSTGRESDB_SSL_CERT | string | '' | Path to the SSL client certificate. |
ssl_key | DB_POSTGRESDB_SSL_KEY | string | '' | Path to the SSL client key. |
Sources: packages/@n8n/config/src/configs/database.config.ts
Executions Configuration
Managed by the ExecutionsConfig class, these settings define the behavior of workflow executions.
| Property | Environment Variable | Type | Default | Description |
|---|---|---|---|---|
timeout | EXECUTIONS_TIMEOUT | number | 3600 | Max time in seconds an execution can run. |
dataPruning | EXECUTIONS_DATA_PRUNING | boolean | true | Whether to prune execution data. |
dataMaxAge | EXECUTIONS_DATA_MAX_AGE | number | 336 | Max age of execution data in hours (14 days). |
saveOnError | EXECUTIONS_DATA_SAVE_ON_ERROR | string | all | When to save execution data on error (all, none). |
saveOnSuccess | EXECUTIONS_DATA_SAVE_ON_SUCCESS | string | all | When to save execution data on success (all, none). |
saveManual | EXECUTIONS_DATA_SAVE_MANUAL | boolean | true | Whether to save data for manual executions. |
storeData | EXECUTIONS_STORE_DATA | string | database | Where to store execution data (database, file). |
process | EXECUTIONS_PROCESS | string | main | How to process executions (main, own). |
timeoutBehavior | EXECUTIONS_TIMEOUT_BEHAVIOR | string | continue | What to do on timeout (continue, fail). |
Sources: packages/@n8n/config/src/configs/executions.config.ts
Security Configuration
Managed by the SecurityConfig class, these settings control various security aspects of the n8n instance.
| Property | Environment Variable | Type | Default | Description |
|---|---|---|---|---|
cookieSameSite | N8N_SECURE_COOKIE_SAME_SITE | string | lax | SameSite attribute for cookies. |
cookieSecure | N8N_SECURE_COOKIE | boolean | true | Secure attribute for cookies. Recommended to keep true. |
cspDisabled | N8N_SECURITY_CSP_DISABLED | boolean | false | Disables the Content-Security-Policy header. |
cspFrameAncestors | N8N_SECURITY_CSP_FRAME_ANCESTORS | string | '' | Defines valid sources for frame-ancestors in CSP. |
trustedProxies | N8N_SECURITY_TRUSTED_PROXIES | string | '' | Comma-separated list of trusted proxy IP addresses. |
ipHeader | N8N_SECURITY_IP_HEADER | string | '' | Header to use for the client's IP address. |
Sources: packages/@n8n/config/src/configs/security.config.ts
System Constants & Limits
While most configurations are managed via environment variables, some hard-coded limits and constants are defined within the codebase. These values are critical for system stability and performance. The file packages/frontend/editor-ui/src/constants.ts contains several such constants that, while part of a frontend package, reflect backend constraints.
| Constant | Value | Description |
|---|---|---|
MAX_WORKFLOW_SIZE | 16777216 (16 MB) | The maximum size of a workflow in bytes. |
MAX_PINNED_DATA_SIZE | 12582912 (12 MB) | The maximum size of pinned data for a node in bytes. |
MAX_DISPLAY_DATA_SIZE | 1048576 (1 MB) | The maximum size of data to be displayed in the UI. |
WEBHOOK_NODE_TYPE | n8n-nodes-base.webhook | The identifier for the Webhook node. |
Sources: packages/frontend/editor-ui/src/constants.ts:11-15, packages/frontend/editor-ui/src/constants.ts:173, packages/nodes-base/nodes/Webhook/Webhook.node.json:2