Skip to content

Database environment variables#

File-based configuration

You can add _FILE to individual variables to provide their configuration in a separate file. Refer to Keeping sensitive data in separate files for more details.

By default, n8n uses SQLite. n8n also supports PostgreSQL. n8n removed support for MySQL and MariaDB in v1.0.

This page outlines environment variables to configure your chosen database for your self-hosted n8n instance.

Variable Type Default Description
DB_TYPE
/_FILE
Enum string:
sqlite, postgresdb
sqlite The database to use.
DB_TABLE_PREFIX * - Prefix to use for table names.

PostgreSQL#

Variable Type Default Description
DB_POSTGRESDB_DATABASE
/_FILE
String n8n The name of the PostgreSQL database.
DB_POSTGRESDB_HOST
/_FILE
String localhost The PostgreSQL host.
DB_POSTGRESDB_PORT
/_FILE
Number 5432 The PostgreSQL port.
DB_POSTGRESDB_USER
/_FILE
String postgres The PostgreSQL user.
DB_POSTGRESDB_PASSWORD
/_FILE
String - The PostgreSQL password.
DB_POSTGRESDB_POOL_SIZE
/_FILE
Number 2 Control how many parallel open Postgres connections n8n should have. Increasing it may help with resource utilization, but too many connections may degrade performance.
DB_POSTGRESDB_CONNECTION_TIMEOUT
/_FILE
Number 20000 Postgres connection timeout (ms).
DB_POSTGRESDB_SCHEMA
/_FILE
String public The PostgreSQL schema.
DB_POSTGRESDB_SSL_CA
/_FILE
String - The PostgreSQL SSL certificate authority.
DB_POSTGRESDB_SSL_CERT
/_FILE
String - The PostgreSQL SSL certificate.
DB_POSTGRESDB_SSL_KEY
/_FILE
String - The PostgreSQL SSL key.
DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED
/_FILE
Boolean true If n8n should reject unauthorized SSL connections (true) or not (false).

SQLite#

Variable Type Default Description
DB_SQLITE_VACUUM_ON_STARTUP Boolean false Runs VACUUM operation on startup to rebuild the database. Reduces file size and optimizes indexes. This is a long running blocking operation and increases start-up time.