Self-hosted n8n gives you unlimited executions and full control of your data. It also makes you responsible for the things a managed platform handles. This is what a production setup needs.

Use Docker

Docker Compose is the sensible deployment. It pins versions, keeps the database alongside the application, and makes upgrades a controlled operation rather than an adventure.

A minimal but production-shaped compose file:

services:
  postgres:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    depends_on: [postgres]
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_DATABASE: n8n
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      N8N_HOST: automation.example.com
      N8N_PROTOCOL: https
      WEBHOOK_URL: https://automation.example.com/
      GENERIC_TIMEZONE: Asia/Karachi
      EXECUTIONS_DATA_PRUNE: "true"
      EXECUTIONS_DATA_MAX_AGE: "336"
    ports:
      - "127.0.0.1:5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  postgres_data:
  n8n_data:

Note the port binding to 127.0.0.1. n8n is not exposed to the internet directly — the reverse proxy handles that.

PostgreSQL, not SQLite

n8n defaults to SQLite, which is fine for trying it out and wrong for production. SQLite handles concurrent writes poorly, and a busy instance with several workflows running at once will contend.

Migrating later is possible and tedious. Start on Postgres.

The encryption key

The most important line in that file, and the one people regret.

N8N_ENCRYPTION_KEY encrypts every credential you store. If you do not set it, n8n generates one and writes it into its data volume. If that volume is lost or you rebuild without it, every stored credential becomes unrecoverable and you re-enter all of them by hand.

Set it explicitly, store it in your password manager, and back it up separately from the server.

HTTPS and the reverse proxy

Put Caddy, Nginx or Traefik in front. Caddy is the least work because it obtains and renews certificates automatically:

automation.example.com {
    reverse_proxy 127.0.0.1:5678
}

That is the entire configuration. Certificates are handled.

Two reasons this matters beyond encryption: many services refuse to send webhooks to a non-HTTPS endpoint, and OAuth flows for integrations generally require it.

Authentication

Enable it before the instance is reachable. An open n8n instance holds credentials for every system you have connected — it is one of the more valuable things an attacker could find.

Use n8n's own user management, and restrict access further at the proxy if the instance only needs to be reachable from known locations. Webhook endpoints need to stay public; the editor does not.

Prune execution data

Every execution is stored. On a busy instance this grows quickly and will eventually fill the disk, at which point workflows fail in confusing ways.

EXECUTIONS_DATA_PRUNE and EXECUTIONS_DATA_MAX_AGE (in hours) handle it. Two weeks of history is usually plenty — long enough to debug something that failed on Friday, short enough to stay bounded.

Also consider saving only failed executions in full. Successful runs rarely need their full payload retained.

Backups

Three things need backing up, and most people only remember the first:

  1. The Postgres database — workflows, credentials, execution history
  2. The n8n data volume — some local state lives here
  3. The encryption key — stored separately, because a backup you cannot decrypt is not a backup

A nightly pg_dump to object storage with a sensible retention policy covers the first. Test a restore at least once; an untested backup is a hypothesis.

Monitoring

You need to know when workflows fail, because silent failure is the characteristic way automation lets you down.

  • An error workflow set as the default error handler, posting failures to Slack or email with the workflow name and error
  • Uptime monitoring on the instance itself
  • Disk space alerting, because pruning can be misconfigured

The error workflow is the important one. Without it, a workflow that has been failing for three weeks looks exactly like one that is working.

Workflows belong in Git

The n8n UI is an editor, not a source of truth. Export workflows as JSON and commit them.

This gives you version history, the ability to review a change before it goes live, and a way to promote a workflow from a staging instance to production deliberately rather than editing production directly.

For anything business-critical, run two instances — staging and production — and never edit production in the browser. It feels like unnecessary process until the first time someone's quick fix sends four hundred emails.

Separate credentials per environment

Staging should not hold production credentials. A test run that emails your actual customer list is a memorable afternoon.

Use separate credentials, and where possible separate accounts, so a mistake in staging cannot reach the real world.

Resource sizing

A modest VPS handles a surprising amount — two cores and four gigabytes of RAM runs most small-business workloads comfortably.

Scale up when you see sustained CPU saturation or memory pressure during peak execution. For genuinely high volume, n8n supports queue mode with separate worker processes, which is the right answer before a bigger single server is.

Upgrades

Pin the image version rather than using latest, so an upgrade is a deliberate act. Read the release notes before moving between major versions, back up first, and upgrade staging before production.

n8n releases frequently. You do not need every release; you do need to not fall two years behind.

The honest trade-off

Self-hosting gives you unlimited executions, full data control and no per-task fee. It costs you a server, upgrades, backups, monitoring and someone to fix it when a third-party API changes.

For high volume or sensitive data, that trade is clearly worth it. For a handful of low-volume workflows, n8n Cloud or even Zapier may genuinely be the better choice, and there is no prize for running infrastructure you did not need.

If you want an instance set up properly, or an existing one audited and hardened, get in touch.