n8n defaults to SQLite, which is fine for development and light production use.
n8n defaults to SQLite, which is fine for development and light production use. Once you exceed roughly 10,000 executions per day or have more than 5 concurrent workflows, SQLite's single-writer lock becomes a bottleneck causing timeouts and data corruption.
Real-world example: An e-commerce company's n8n instance handles webhook events from Shopify, Stripe, and shipping providers. During peak hours, workflows start failing with SQLITE_BUSY errors.
# .env configuration for PostgreSQL
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=your-postgres-host
DB_POSTGRESDB_PORT=5432
DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=n8n_user
DB_POSTGRESDB_PASSWORD=your-secure-password
DB_POSTGRESDB_SCHEMA=public
# Connection pool settings for high throughput
DB_POSTGRESDB_POOL_SIZE=20
```text
```yaml
# docker-compose.yml with PostgreSQL
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: n8n
POSTGRES_USER: n8n_user
POSTGRES_PASSWORD: your-secure-password
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n_user -d n8n"]
interval: 5s
timeout: 5s
retries: 5
n8n:
image: n8nio/n8n:latest
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n_user
- DB_POSTGRESDB_PASSWORD=your-secure-password
depends_on:
postgres:
condition: service_healthy
```text
> **Danger: Migration Required**
>
> There is no built-in migration tool from SQLite to PostgreSQL. You must export your workflows as JSON, set up the new database, import the workflows, and re-enter credentials. Plan this migration during a maintenance window.
**Related:** [Flatten Deeply Nested API Responses](../code-node-mastery/01-flatten-deeply-nested-api-responses.md) | [Use Docker Compose with Health Checks for n8n and PostgreSQL](../self-hosting-operations/01-use-docker-compose-with-health-checks-for-n8n-and-postgresql.md)
I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.