n8n on a VPS: The Complete Setup

n8n is the automation tool people self-host because the cloud tiers get expensive fast. Here's the full route on a cheap VPS.

Bottom line: you can run n8n production-style on a 1–2 GB VPS for $5–7/mo. For anyone running more than a couple of test workflows, self-hosting n8n pays for itself almost immediately — the paid cloud plans run more per month than a year of VPS.

Spec note: n8n on a 1 GB box is fine for light-to-moderate workflows. If you're running many scheduled jobs, a 2 GB box gives comfortable headroom. See the RAM sizing guide for the workload thresholds.

Why self-host n8n

The 1-command Docker setup (local/test only)

n8n runs great in Docker. For a quick local test on a fresh VPS:

# assume Docker is installed — see our Docker starter stack
mkdir -p ~/n8n && cd ~/n8n
docker run -d --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_SECURE_COOKIE=false \
  n8nio/n8n

⚠️ Local/test only — do not use this for production. This binds n8n on port 5678 with no TLS and N8N_SECURE_COOKIE=false. If this is exposed beyond localhost, anyone can hit your instance on http://your-vps:5678 in plaintext, and the insecure-cookie flag weakens session protection. It's fine for a 10-minute smoke test on 127.0.0.1; do not point it at a public IP.

The production path: Docker Compose + Caddy (TLS)

For anything you're going to actually run automation on, front n8n with Caddy so it gets automatic HTTPS and a secure cookie. This is the setup we recommend — it's barely more work than the one-liner above and it's the difference between "runs" and "safe to run."

# ~/n8n/docker-compose.yml  (n8n + Caddy, automatic TLS)
services:
  n8n:
    image: n8nio/n8n
    environment:
      - N8N_HOST=automation.yourdomain.com
      - N8N_PROTOCOL=https
      - N8N_PORT=5678
    volumes:
      - n8n_data:/home/node/.n8n
    # port 5678 stays INTERNAL — only Caddy is exposed
  caddy:
    image: caddy:2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
volumes:
  n8n_data:
  caddy_data:
# Caddyfile — automatic Let's Encrypt TLS, only port 443 exposed
automation.yourdomain.com {
    reverse_proxy n8n:5678
}

With this, n8n is only reachable internally on port 5678; the only public exposure is port 443 (HTTPS) via Caddy. Set N8N_SECURE_COOKIE=true here — n8n is behind TLS, so the secure cookie is correct and expected.

Realistic VPS needs

WorkloadRAMGood pick
A few hobby workflows1 GB$1.5–6
Active production automation2 GB~$7–12
n8n + other services (Uptime Kuma, etc.)2 GB+Scale up
Recommended boxes for n8n: Vultr (reliable, global) or DigitalOcean (great docs). Budget? RackNerd. Affiliate disclosure: signups through these links may earn us a commission.

New to VPS hosting entirely? Read when a VPS makes sense and lock it down first.

Get an n8n-ready VPS →