Tips > Reliability & Performance

Switch From SQLite to PostgreSQL at Scale

n8n defaults to SQLite, which is fine for development and light production use.

n8n defaults to SQLite, which suits development and light use. Past roughly 10,000 executions per day or more than five concurrent workflows, SQLite's single-writer lock causes timeouts and data corruption. Switch the database to PostgreSQL by setting DB_TYPE and the connection variables, and add a connection pool for high throughput.

When should you move from SQLite to PostgreSQL?

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.

How do you configure PostgreSQL for n8n?


# .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

A Docker Compose setup with PostgreSQL and a health check:


# 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

What does the migration involve?

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 · Use Docker Compose with Health Checks for n8n and PostgreSQL

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

190 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book an introductory call