dom4in.net
← All resources
Guide · n8n

Self-host n8n for workflow automation

One container gives you a visual automation builder with hundreds of integrations and no per-task pricing — the tool teams reach for in 2026 when Zapier bills outgrow Zapier value.

The process

The full path from container to a production webhook workflow. The encryption key in step one is the thing you must not lose — it guards every stored credential.

Directions

1Start n8n with Docker and Postgres

n8n runs fine from a single container with SQLite, but if this is going to matter, start on Postgres — migrating later is more work than starting right. A small compose file with n8n plus postgres and two named volumes is the standard shape.

Set N8N_ENCRYPTION_KEY explicitly to a value you store in your password manager. n8n encrypts every saved credential with it; lose the key and every stored connection must be re-entered by hand.

n8n:
  image: n8nio/n8n
  environment:
    - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
    - DB_TYPE=postgresdb
    - DB_POSTGRESDB_HOST=db
    - WEBHOOK_URL=https://n8n.example.com/
  volumes: ["n8ndata:/home/node/.n8n"]

2Put it on a subdomain with TLS

Front n8n with your reverse proxy (Traefik, Caddy, nginx) on a subdomain like n8n.example.com with a real certificate, and set WEBHOOK_URL to that public URL — inbound webhooks and OAuth callbacks are generated from it, and they silently break if it still says localhost.

Turn on n8n's user management (owner account + members) rather than running it wide open behind basic auth; workflow-level sharing needs real users.

3Build a webhook-to-action workflow

The canonical first workflow: a Webhook trigger node, a transform (Set or Code node), and an action (Slack message, email, HTTP request). Build it in the editor, execute once with test data to see values flow between nodes, then activate.

Active workflows get a production webhook URL distinct from the test one — point the sending service at the production path, and remember n8n only listens while the workflow is active.

4Store credentials once, reference everywhere

Add each external service (Slack, SendGrid, your DB) under Credentials once; every node references it by name. OAuth-based credentials walk you through consent using the callback URL derived from WEBHOOK_URL — which is why step two came first.

Scope API keys to what the workflow needs. An automation platform is a credential store with superpowers, and it deserves the same care as a secrets vault.

5Executions, retries, and backups

Turn on saved executions for failures (at minimum) so you can replay a failed run with its original data after fixing the workflow. Add an error workflow — a special workflow that fires when any other fails — to get a Slack ping instead of silent breakage.

Back up the Postgres database and the encryption key; together they are the full instance. Version-control critical workflows by exporting their JSON — n8n also has built-in git-backed source control on paid tiers.

Common issues & fixes

Webhooks work in test but 404 in production.

The workflow isn't activated, or the caller uses the test URL. Activate the workflow and use the production webhook path shown on the trigger node.

OAuth credential setup fails with a redirect mismatch.

WEBHOOK_URL doesn't match the URL you're actually on. Set it to the exact public https:// hostname and recreate the credential.

All credentials show as unusable after a restore.

The restore has a different N8N_ENCRYPTION_KEY than the backup. Restore the original key — without it, stored credentials are unrecoverable by design.

The instance slows down over weeks.

Execution history is unbounded by default. Set EXECUTIONS_DATA_MAX_AGE / pruning envs so old run data gets cleaned up.

A scheduled workflow ran twice.

Two n8n instances share the same database without queue mode. Run a single instance, or configure queue mode with workers properly.

Honesty note: articles are drafted with AI assistance, then a human checks each one against the vendor's current setup flow before it publishes — nothing goes live unreviewed. Vendor interfaces still change; if a step looks different, the underlying record is what matters.