VPS

How to Self-Host n8n on a VPS (Docker, Step by Step)

11 min read

How to Self-Host n8n on a VPS (Docker, Step by Step)

The Short Answer

To self-host n8n on a VPS, rent a 2 vCPU / 4 GB server (8 GB is comfortable), point a subdomain at it, and run n8n with Docker Compose alongside PostgreSQL behind a reverse proxy that provides HTTPS. The cheapest sensible server for the job today is the Contabo Cloud VPS 4 at $5.28 a month on a 24-month term ($126.72 prepaid; $6.60 a month billed monthly): 4 vCPUs, 8 GB of RAM and 100 GB of SSD storage — double n8n’s documented minimum, with room for other self-hosted tools. If you prefer NVMe storage and weekly backups included, the Hostinger KVM 2 costs $8.79 a month on a 24-month term ($210.96 upfront, renewing at $14.99 a month) for 2 vCPUs, 8 GB of RAM and 100 GB of NVMe. If you want hourly billing with no prepay, Hetzner’s CPX22 (2 AMD vCPUs, 4 GB RAM, 80 GB NVMe) costs €16.99 a month in Helsinki or €19.99 in Nuremberg, and DigitalOcean’s Basic 2 vCPU / 4 GiB Droplet costs $24.00 a month.

The software itself costs nothing: the self-hosted Community Edition is free for your own internal use with no vendor limit on executions. n8n Cloud instead meters them — Starter is €20 a month billed annually for 2,500 executions a month. One workflow checking every five minutes runs about 8,640 times a month alone, over three times that allowance. On your own server it costs the same flat bill as a daily job.

Every price below was checked on the provider’s own pricing page on November 25, 2026. Prices change often, so confirm the live price before you buy.

What n8n Is — and Why People Self-Host It

n8n is a workflow automation tool: you connect apps, APIs, AI models and scripts as nodes on a canvas, and the workflows then run on their own — receive an email, write it to a spreadsheet, send a Telegram message, call an AI model. One execution is one complete run of a workflow, however many steps it contains.

People self-host for cost shape (Cloud charges per execution; a server charges the same at any volume), data control (credentials stay on your machine), and freedom (community nodes, internal-network access, your own backup rules). The trade-off is responsibility: n8n recommends self-hosting for users comfortable managing servers, and you own updates, backups, certificates and the firewall.

What Size VPS Does n8n Need?

n8n’s Docker Compose documentation states a minimum of 2 vCPUs and 4 GB of RAM for the current production stack. Treat that as the floor. This guide runs four containers — n8n, a separate task-runner that executes Code nodes, PostgreSQL, and a reverse proxy — and memory use grows with payload size and how many workflows run at once.

  • 2 vCPU / 4 GB RAM / 40–80 GB disk runs n8n with PostgreSQL for personal and light business use: dozens of workflows, modest payloads.
  • 4 vCPU / 8 GB RAM is comfortable if workflows process files, run in parallel, or share the server with other tools. Every 8 GB plan below costs less than the 4 GB plans from the hourly-billed clouds, which is why they lead this guide.
  • Disk grows with history. Execution logs and the database accumulate. Set an execution-data retention limit from day one, or a busy instance will quietly fill a small disk.

Our VPS sizing guide covers sizing for other workloads if this server will do more than n8n, and our roundup of the best VPS for self-hosting ranks the same providers for a broader self-hosted stack.

Two traps to avoid. Do not buy a 1 GB server because a quickstart container fits: the single-container SQLite setup is for trying n8n out, but n8n recommends PostgreSQL for production, because SQLite locks under parallel executions. And do not pay for a GPU: n8n is CPU work, and calling an AI provider’s API needs no local GPU.

The Best VPS Options for n8n Compared

Provider Price Specs Term Best for
Contabo Cloud VPS 4 $5.28/mo 4 vCPU, 8 GB RAM, 100 GB SSD 24 months prepaid ($126.72) Lowest flat bill, most RAM per dollar
Hostinger KVM 2 $8.79/mo 2 vCPU, 8 GB RAM, 100 GB NVMe 24 months prepaid ($210.96), renews $14.99/mo NVMe speed plus weekly backups included
Hetzner CPX22 €16.99–€19.99/mo 2 AMD vCPU, 4 GB RAM, 80 GB NVMe Hourly, monthly cap, no prepay EU hosting, pay-as-you-go, 20 TB traffic
DigitalOcean Basic 4 GiB $24.00/mo 2 vCPU, 4 GiB RAM, 80 GiB SSD Per-second billing, monthly cap Easiest console and docs for a first server

Contabo also sells the Cloud VPS 4 at $5.61 a month on 12 months ($67.32 prepaid) and $6.60 a month billed monthly plus a $2.40 setup fee. DigitalOcean’s 2 vCPU / 2 GiB plan at $18.00 a month runs the stack, but 2 GiB leaves little headroom; the 4 GiB plan is the honest starting point there.

1. Contabo Cloud VPS 4 — Lowest Flat Bill

Price: $5.28 a month for 24 months ($126.72 prepaid), $5.61 a month on 12 months ($67.32 prepaid), or $6.60 a month billed monthly plus a $2.40 setup fee: 4 vCPUs, 8 GB RAM, 100 GB SSD, 200 Mbit/s port, one snapshot, unlimited traffic under fair use.

Why it wins: double n8n’s minimum CPU and RAM for the lowest monthly rate, and the flat bill is the whole point of self-hosting — executions are unlimited, so a polling workflow costs nothing extra. The included snapshot is a simple whole-server restore point before upgrades.

Watch out for: the headline price needs a 24-month prepay, storage is SSD rather than NVMe, support is ticket-based, and non-EU locations can carry a monthly location fee — check the configurator total before committing.

Best for: anyone running n8n for a year or more who wants the lowest predictable bill.

2. Hostinger KVM 2 — NVMe and Backups Included

Price: $8.79 a month on 24 months ($210.96 upfront), renewing at $14.99 a month: 2 vCPUs, 8 GB RAM, 100 GB NVMe, 8 TB bandwidth on a 1 Gbps network, free weekly backups.

Why it works: NVMe makes database-heavy execution history snappier than SSD, RAM matches Contabo’s headroom, and included weekly backups cover the laziest failure mode — forgetting to back up.

Watch out for: the intro price is a 24-month prepay and renewal is close to double, so the second term costs materially more. There is no monthly-billed equivalent at this price.

Best for: self-hosters who want NVMe speed and built-in backups and are happy to prepay two years.

3. Hetzner CPX22 — Hourly Billing in Europe

Price: €16.99 a month in Helsinki (HEL1) or €19.99 in Nuremberg (NBG1), including one IPv4 address and excluding VAT, billed hourly up to the monthly maximum: 2 AMD vCPUs, 4 GB RAM, 80 GB NVMe, 20 TB included traffic in European locations.

Why it works: no prepay and no renewal jump — pay for the hours the server exists, delete it and billing stops. Ideal for testing n8n for a month before committing, with European locations keeping data under GDPR.

Watch out for: Hetzner’s cheaper CX23 (2 vCPUs / 4 GB / 40 GB at €5.99 a month including IPv4) showed as “currently not available” on November 25, 2026, as it has for months. Plan around the CPX22 price.

Best for: European users, GDPR-sensitive data, and trialling self-hosting without a long prepay.

4. DigitalOcean Basic 4 GiB — Easiest First Server

Price: $24.00 a month: 2 vCPUs, 4 GiB RAM, 80 GiB SSD, 4,000 GiB outbound transfer, billed per second with a monthly cap (per-second billing applies from January 1, 2026).

Why it works: the friendliest console and documentation here, one-click Docker images, and per-second billing so a weekend experiment costs cents. If this is your first server, the smooth setup beats saving a few dollars.

Watch out for: the most expensive way to buy 4 GB in this comparison, with capped transfer — though 4,000 GiB is far beyond what n8n workflows normally move.

Best for: beginners who value documentation and a gentle learning curve over the lowest price.

Step by Step: Install n8n with Docker Compose

You need a VPS running Ubuntu 24.04 LTS with SSH access, a domain or subdomain you control (this guide uses n8n.example.com), about half an hour, and a password manager. The setup follows n8n’s Docker Compose approach: n8n plus PostgreSQL plus a separate runner, behind a reverse proxy with automatic HTTPS.

Step 1 — DNS. Add an A record for n8n pointing to your server’s public IPv4 address. Ports 80 and 443 must be reachable: the proxy needs them for the HTTPS certificate, and external services need them for webhooks. Let DNS propagate for a few minutes.

Step 2 — Docker. Install Docker Engine and the Compose plugin from Docker’s official repository, as in our guide to installing Docker on a VPS, then verify with docker --version and docker compose version. On a new server, harden it first — SSH keys, automatic updates, a minimal firewall — per our guide to securing your VPS. Note that Docker-published ports bypass some host firewall rules, which is why only the reverse proxy publishes ports here; n8n and PostgreSQL stay on the internal Compose network.

Step 3 — Secrets. Create /opt/n8n and a .env file (chmod 600) holding three random values: an encryption key, a database password, and a runner token. Set the encryption key explicitly before first boot and back it up in your password manager: n8n encrypts every stored credential with it, and losing it permanently breaks those credentials. Never commit the .env file anywhere public.

Step 4 — Compose file. Create compose.yaml with four services: postgres (PostgreSQL 16+, named volume, healthcheck); n8n (official image pinned to a stable version, DB_TYPE=postgresdb, domain/HTTPS/webhook URL/timezone set, named volume); n8n-runner (separate Code-node execution, as n8n recommends for production); and caddy publishing only ports 80/443 with automatic Let’s Encrypt HTTPS while n8n binds to localhost:5678. Set WEBHOOK_URL to your public HTTPS address and N8N_PROXY_HOPS=1.

Step 5 — Claim the owner account first. The first person to open a fresh n8n creates the owner account — if the proxy is already public, a stranger who finds your subdomain first can claim your instance. Start only n8n (docker compose up -d n8n), reach it through an SSH tunnel, create the owner account, and only then start the proxy.

Step 6 — Verify. Run docker compose up -d, follow docker compose logs -f n8n, open https://n8n.example.com, and fire a test webhook workflow. If the webhook URL shows the wrong host or protocol, fix WEBHOOK_URL and proxy settings before anything else.

Step 7 — Backups and updates. Back up the PostgreSQL database (scheduled pg_dump), the n8n data volume, and the encryption key plus .env in a password manager — and test a restore once. To update: read the release notes, snapshot or dump first, bump the pinned version, then docker compose pull and docker compose up -d. Set an execution-data retention limit so history does not grow without bound.

Self-Hosted vs n8n Cloud: When Not to Self-Host

Self-hosting wins on cost per execution, data control and flexibility. Cloud wins on time: no patching, backups or certificates, and vendor support. Starter at €20 a month billed annually includes 2,500 executions — roughly 83 runs a day — with five concurrent executions. If your automations run a few times a day, Cloud is simpler and predictable.

Self-host when a workflow polls every few minutes, webhooks arrive in bursts, credentials must stay on your infrastructure, or you want community nodes and internal-network access. Do not self-host if you never want to touch SSH or backups — Cloud is the honest answer there. And read the licence before hosting for clients: the free Community Edition covers your own internal use under n8n’s Sustainable Use License; reselling n8n as a service is a different arrangement.

FAQ

Can I run n8n on a 1 GB or 2 GB server?
For a test, yes; for production, no. n8n’s Compose documentation states 2 vCPUs and 4 GB of RAM as the minimum for the stack with PostgreSQL and the runner. Buy 4 GB minimum, 8 GB for parallel workflows or large payloads.

SQLite or PostgreSQL?
SQLite is the default and fine for trying things out. For production — parallel executions, round-the-clock workflows — use PostgreSQL: no lock errors under concurrency, and easier backups.

Do I need a domain name?
Yes, beyond a local test. Logins, OAuth callbacks and external webhooks expect a public HTTPS address. A subdomain with an A record is enough; the proxy gets the certificate for free.

What happens if I lose the encryption key?
Every stored credential becomes permanently unreadable. Set the key before first boot, keep a copy in a password manager, and include it in backups. It is the most common self-hosting disaster, and entirely preventable.

How much does self-hosted n8n cost per month?
The software is free for internal use; you pay only for the server — $5.28–$6.60 at Contabo depending on term, $8.79 at Hostinger (24-month term), €16.99–€19.99 at Hetzner billed hourly, or $24.00 at DigitalOcean, with no per-execution fees at any volume.

The Bottom Line

Self-host n8n when executions are frequent, bursty or sensitive: a flat server bill replaces per-execution metering, and credentials never leave your machine. Buy at least 2 vCPUs and 4 GB of RAM — Contabo’s Cloud VPS 4 at $5.28 a month (24-month term) is the cheapest comfortable option, Hostinger’s KVM 2 at $8.79 adds NVMe and weekly backups, Hetzner’s CPX22 at €16.99–€19.99 keeps billing hourly in Europe, and DigitalOcean’s $24.00 Basic Droplet is the gentlest first server. Run Docker Compose with PostgreSQL and the separate runner, expose only the reverse proxy, claim the owner account before going public, and back up the database and encryption key from day one.

Sources: Contabo VPS and pricing pages (contabo.com/en/vps, contabo.com/en/pricing), Hostinger VPS hosting page (hostinger.com/vps-hosting), Hetzner Cloud Regular Performance and Cost-Optimized pages (hetzner.com/cloud/regular-performance, hetzner.com/cloud/cost-optimized), DigitalOcean Droplet pricing (digitalocean.com/pricing/droplets), n8n pricing page (n8n.io/pricing) and n8n Docker Compose documentation, all checked November 25, 2026.

Leave a Reply

Your email address will not be published. Required fields are marked *