Skip to content
Book a free call
Easify AI

How to Deploy n8n Self-Hosted: A Step-by-Step Guide on DigitalOcean / AWS / Kubernetes

By Shaghil Shahzad, Easify AI · · 8 min read · Updated

Creating a new DigitalOcean droplet to deploy n8n self-hosted

Self-hosting n8n gives you no execution limits, full control over where data lives and no licence fee for the Community Edition. In return, you own the server: setup, HTTPS, backups and updates.

This guide shows a production-ready setup that works the same on DigitalOcean, AWS EC2 or Hetzner, then how to move to Kubernetes when you outgrow one server. Commands and settings are checked against the n8n 2.x documentation as of November 2026.

Choose where to run it

Every option below runs the same Docker Compose stack. The difference is price and how much else you already run there.

Platform Example size From (November 2026) Good fit
Hetzner Cloud CX23: 2 vCPU, 4 GB RAM €5.99/month excl. VAT EU teams on a budget
DigitalOcean Basic Droplet: 2 vCPU, 4 GB RAM $24/month Simple setup, good docs
AWS EC2 t3.small: 2 vCPU, 2 GB RAM about $15/month on demand in us-east-1, plus storage and public IPv4 Teams already on AWS
Kubernetes (EKS, DOKS, others) 2+ nodes, plus Redis and PostgreSQL Varies widely Queue mode at scale

Not sure self-hosting is cheaper for you? Our n8n Cloud vs self-hosting cost guide compares the two, including the time cost.

What changed in n8n 2.x for self-hosters

n8n 2.0 went stable in December 2025. Older guides, including the first version of this one, now give advice that breaks or is unsafe:

Change What to do
latest and next tags renamed stable and beta Pin an exact version, such as 2.47.7
MySQL and MariaDB no longer supported for n8n's own database Use PostgreSQL (or SQLite for testing)
Code nodes run in task runners by default Use external mode with the n8nio/runners image in production
Code nodes cannot read environment variables by default Use credentials instead of $env
Execute Command and Local File Trigger nodes disabled by default Re-enable only if you need them, with NODES_EXCLUDE
Activate/Deactivate replaced by Publish/Unpublish Saving no longer pushes changes live
WEBHOOK_URL renamed N8N_WEBHOOK_URL in recent 2.x releases The old name still works but logs a warning

Part 1: one server with Docker Compose

This is the setup we recommend for most teams. It runs n8n, PostgreSQL and Caddy (for automatic HTTPS) on one server.

Step 1: create the server

  1. Create an Ubuntu 24.04 LTS server: a DigitalOcean Droplet, an EC2 instance or a Hetzner Cloud server.
  2. Add your SSH key; don't use password login.
  3. Open only ports 22, 80 and 443 in the provider's firewall (on AWS, the security group).
  4. On AWS, attach an Elastic IP so the address survives restarts.
  5. Point a DNS A record, such as n8n.yourcompany.com, at the server's IP.

Step 2: install Docker

Install Docker Engine and the Compose plugin from Docker's official repository, following docs.docker.com/engine/install/ubuntu. Don't use the older docker.io and docker-compose packages from Ubuntu's own repositories, which many older guides suggest.

Then check both work:

docker --version
docker compose version

Step 3: create the configuration

mkdir -p ~/n8n && cd ~/n8n
openssl rand -hex 32   # use the output as N8N_ENCRYPTION_KEY
openssl rand -hex 24   # use the output as the database password
openssl rand -hex 24   # use the output as the runners token

Create a .env file:

N8N_VERSION=2.47.7
N8N_HOST=n8n.yourcompany.com
N8N_ENCRYPTION_KEY=paste-the-first-value
POSTGRES_PASSWORD=paste-the-second-value
RUNNERS_AUTH_TOKEN=paste-the-third-value
GENERIC_TIMEZONE=Europe/London

2.47.7 was the stable release when we checked in November 2026. Use the current stable version from n8n's docs when you set up.

Watch out: n8n encrypts stored credentials with N8N_ENCRYPTION_KEY. If you lose it, a restored database is useless because no credential can be decrypted. Store it in your password manager the moment you create it.

Step 4: write the compose file

Create compose.yaml:

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
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"]
      interval: 10s
      retries: 5

  n8n:
    image: n8nio/n8n:${N8N_VERSION}
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - N8N_HOST=${N8N_HOST}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_WEBHOOK_URL=https://${N8N_HOST}/
      - N8N_PROXY_HOPS=1
      - NODE_ENV=production
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - TZ=${GENERIC_TIMEZONE}
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_RUNNERS_MODE=external
      - N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0
      - N8N_RUNNERS_AUTH_TOKEN=${RUNNERS_AUTH_TOKEN}
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=336
    volumes:
      - n8n_data:/home/node/.n8n

  runners:
    image: n8nio/runners:${N8N_VERSION}
    restart: unless-stopped
    depends_on:
      - n8n
    environment:
      - N8N_RUNNERS_TASK_BROKER_URI=http://n8n:5679
      - N8N_RUNNERS_AUTH_TOKEN=${RUNNERS_AUTH_TOKEN}

  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    command: caddy reverse-proxy --from ${N8N_HOST} --to n8n:5678
    volumes:
      - caddy_data:/data

volumes:
  postgres_data:
  n8n_data:
  caddy_data:

A few notes on the choices:

  • No port 5678 on the host. Only Caddy is exposed, so n8n is reachable over HTTPS only.
  • The runners image version must match n8n's. Both use ${N8N_VERSION}, so they move together.
  • If you use the Python Code node, add N8N_NATIVE_PYTHON_RUNNER=true to the n8n service, as in n8n's task runner example.
  • n8n's own docs use Traefik as the proxy, and the official n8n-hosting repository has a Caddy example. Either works; Caddy keeps the file shorter.

Step 5: start it

docker compose up -d
docker compose logs -f n8n

When the logs show the editor is ready, open https://n8n.yourcompany.com and create the owner account straight away. Until you do, anyone who finds the URL can.

Tip: On older 2.x versions that do not recognise N8N_WEBHOOK_URL, use WEBHOOK_URL instead. If webhook URLs in the editor show http:// or the wrong host, this variable or N8N_PROXY_HOPS is usually the cause.

Part 2: make it production-ready

A running instance is not yet a safe one. Before real workflows go on it:

  1. Back up nightly. Dump PostgreSQL with pg_dump and copy the file off the server, for example to object storage. Keep the encryption key separately.
  2. Test a restore onto a fresh server at least once.
  3. Monitor from outside. Point an uptime monitor at /healthz/readiness, which returns 200 when the database is connected.
  4. Set up error alerts. Give every production workflow an error workflow, as in our n8n error handling guide.
  5. Plan updates. Read the release notes, back up, change N8N_VERSION, then docker compose pull && docker compose up -d.
  6. Patch the OS. Turn on unattended security updates for Ubuntu.
  1. TriggerNightly schedule

    02:00 server time

    n8n
  2. StepDump the database

    pg_dump to a dated file

    PostgreSQL
  3. StepCopy off the server

    Object storage, 30 days kept

  4. YouMonthly restore test

    Someone restores and checks it

  5. ResultRecoverable instance

    Database plus encryption key

Part 3: scaling up with queue mode

One instance handles a lot. When executions start queuing at busy times, the next step is queue mode, which is available in the free Community Edition.

Component Role
Main instance Editor, API, triggers and timers
Redis Queue of executions waiting to run
Workers (n8n worker) Run the executions; 10 at a time each by default
PostgreSQL Shared database; SQLite is not supported
Webhook processors (optional) Take incoming webhook traffic behind a load balancer

To switch, set EXECUTIONS_MODE=queue on the main instance and every worker, point them all at the same Redis and PostgreSQL, and give every one the same N8N_ENCRYPTION_KEY. n8n recommends a worker concurrency of 5 or more. Each worker also needs its own runners sidecar.

The official n8n-hosting repository on GitHub has a withPostgresAndWorker Compose example, which is the easiest way to try queue mode before moving to Kubernetes.

Note: Running several main instances for high availability (multi-main) needs a self-hosted Enterprise licence. Without it, run one main instance and scale workers.

Part 4: Kubernetes with the official Helm chart

On Kubernetes, use n8n's own Helm chart from the n8n-hosting repository rather than hand-written manifests:

helm install n8n oci://ghcr.io/n8n-io/n8n-helm-chart/n8n -f my-values.yaml

The chart's README and the charts/n8n/examples folder show values files for different setups. Whatever you configure, the same rules apply as on one server:

  • PostgreSQL and Redis run as managed services (Amazon RDS and ElastiCache, DigitalOcean Managed Databases) or in the cluster.
  • Persistent volumes or an external database hold all state; pods must be disposable.
  • One main replica unless you have Enterprise multi-main. Scale workers instead.
  • Ingress with TLS, for example NGINX Ingress with cert-manager.
  • The encryption key comes from a Kubernetes Secret, identical on every pod.

Watch out: The first version of this guide showed a plain Deployment with replicas: 2 and no queue mode. Two independent main instances on one database will both fire schedules and triggers, so runs happen twice. Don't do that.

Troubleshooting

Problem Likely cause
Site not reachable DNS not pointing at the server, or ports 80/443 closed
Certificate errors DNS not propagated when Caddy first requested the certificate; restart Caddy
Webhooks show the wrong URL N8N_WEBHOOK_URL or N8N_PROXY_HOPS not set
Credentials fail after a restore A different N8N_ENCRYPTION_KEY
Code nodes fail after upgrading to 2.x Runners image missing or on a different version
Workflows run twice Two main instances without multi-main

Before your first workflow handles real customer data, work through our n8n go-live checklist. If you would rather not run the server yourself, setting up and looking after self-hosted n8n is part of our reliable n8n automations work.

Summary

  • Start simple: one Ubuntu server with Docker Compose, PostgreSQL and Caddy suits most teams on DigitalOcean, AWS or Hetzner.
  • Protect the key: set N8N_ENCRYPTION_KEY yourself and store it outside the server.
  • Follow 2.x defaults: pin an exact version, use PostgreSQL, and run Code nodes in external task runners.
  • Make it safe: nightly off-site backups, a tested restore, external uptime checks and error alerts.
  • Scale with workers: queue mode first, then Kubernetes with n8n's official Helm chart, keeping one main instance.

Frequently asked questions

How much RAM does self-hosted n8n need?
For a small team, 2 GB works for light use and 4 GB gives comfortable headroom with PostgreSQL on the same server. Memory use depends far more on how much data your workflows carry than on the number of workflows, so watch real usage and resize if needed.
Can I run self-hosted n8n with SQLite?
Yes, SQLite is the default and fine for testing or very light use. For production, use PostgreSQL. n8n 2.0 removed MySQL and MariaDB as storage databases, and queue mode does not support SQLite.
Do I need Kubernetes to self-host n8n?
No. A single server with Docker Compose handles most small and medium workloads. Kubernetes makes sense when you need queue mode with several workers, or your organisation already runs everything on it.
How do I update self-hosted n8n?
Read the release notes for breaking changes, back up the database and encryption key, change the pinned image version in your compose file, then run docker compose pull and docker compose up -d. Test a few key workflows afterwards.