Self-host n8n (Postgres) with Docker
n8n backed by Postgres instead of its default SQLite file, for production workflow volumes.
This page describes the Levelrail template for n8n (Postgres) (Automation). It deploys the services below as one Docker Compose app on your own server.
Project site: https://docs.n8n.io/hosting/installation/server-setups/postgresql/.Recommended memory: about 1024 MiB.
Services, ports and volumes
| Service | Image | Container ports | Volumes |
|---|---|---|---|
n8n | n8nio/n8n:2.10.2 | 5678 | n8n_postgres_data -> /home/node/.n8n |
postgres | postgres:16-alpine | none | n8n_postgres_db_data -> /var/lib/postgresql/data |
Environment variables
| Service | Variable | Value |
|---|---|---|
n8n | DB_POSTGRESDB_DATABASE | Preset in the template |
n8n | DB_POSTGRESDB_HOST | Preset in the template |
n8n | DB_POSTGRESDB_PASSWORD | Generated at deploy |
n8n | DB_POSTGRESDB_PORT | Preset in the template |
n8n | DB_POSTGRESDB_USER | Preset in the template |
n8n | DB_TYPE | Preset in the template |
n8n | N8N_ENCRYPTION_KEY | Generated at deploy |
n8n | N8N_PORT | Preset in the template |
n8n | N8N_PROTOCOL | Preset in the template |
n8n | WEBHOOK_URL | Preset in the template |
postgres | POSTGRES_DB | Preset in the template |
postgres | POSTGRES_PASSWORD | Generated at deploy |
postgres | POSTGRES_USER | Preset in the template |
Passwords and keys marked as generated are created for you when the app is deployed and stored as secrets. Values are not shown here.
Deploy n8n (Postgres) with Levelrail
In the dashboard, open Apps, choose New app, then Browse templates, and select n8n (Postgres). Review the Compose body and deploy.
With the CLI:
levelrail-cli templates deploy n8n-postgres --name my-n8n-postgresSee Service template catalog for how templates work, and Getting started if you have not installed Levelrail yet.
More Automation templates
All templates are listed in the self-host gallery.