How do you self-host n8n on a VPS?
Quick Answer: Self-host n8n by provisioning a VPS (minimum 2 vCPU, 4 GB RAM — Hetzner CX22 at EUR 5.50/month is a strong option), installing Docker, creating a docker-compose.yml with PostgreSQL, setting up a reverse proxy with SSL (Caddy is simplest), and configuring automated backups. Production deployments should use PostgreSQL (not SQLite) and include daily pg_dump backups.
Why Self-Host n8n
Self-hosting n8n eliminates per-execution pricing, gives teams full control over data residency, and allows connecting to internal services behind your firewall. The community edition is free with unlimited workflows and executions. The trade-off is that you are responsible for infrastructure, updates, and backups.
Step 1: Choose a VPS Provider
n8n runs well on any Linux VPS. Common choices:
| Provider | Minimum Plan | Monthly Cost | Notes |
|---|---|---|---|
| Hetzner | CX22 (2 vCPU, 4 GB) | EUR 5.50 | Best price/performance in EU |
| DigitalOcean | Basic (2 vCPU, 4 GB) | $24 | Good documentation |
| AWS Lightsail | Medium (2 vCPU, 4 GB) | $20 | AWS ecosystem integration |
| Contabo | VPS S (4 vCPU, 8 GB) | EUR 6.99 | Budget option, larger specs |
Step 2: Minimum Server Specifications
- CPU: 2 vCPU (4 vCPU recommended for 20+ active workflows)
- RAM: 4 GB (8 GB recommended for heavy workloads)
- Storage: 20 GB SSD minimum
- OS: Ubuntu 22.04 LTS or Debian 12
Step 3: Install Docker and Docker Compose
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
# Install Docker Compose plugin
sudo apt install docker-compose-plugin -y
# Verify installation
docker --version
docker compose version
Step 4: Create Docker Compose Configuration
Create a directory for n8n and the configuration file:
mkdir -p /opt/n8n && cd /opt/n8n
Create docker-compose.yml:
version: "3.8"
services:
n8n-db:
image: postgres:16-alpine
restart: always
environment:
POSTGRES_DB: n8n
POSTGRES_USER: n8n
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n"]
interval: 10s
timeout: 5s
retries: 5
n8n:
image: n8nio/n8n:latest
restart: always
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=n8n-db
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=${DB_PASSWORD}
- N8N_HOST=${N8N_HOST}
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://${N8N_HOST}/
- N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
- GENERIC_TIMEZONE=UTC
volumes:
- n8n_data:/home/node/.n8n
depends_on:
n8n-db:
condition: service_healthy
volumes:
db_data:
n8n_data:
Step 5: Configure PostgreSQL
Create a .env file:
N8N_HOST=n8n.yourdomain.com
DB_PASSWORD=$(openssl rand -base64 24)
ENCRYPTION_KEY=$(openssl rand -hex 16)
PostgreSQL is required for production deployments. SQLite (the default) does not handle concurrent executions reliably and lacks proper backup tooling.
Step 6: Set Up a Reverse Proxy with SSL
Install Caddy for automatic HTTPS:
sudo apt install -y caddy
Add to /etc/caddy/Caddyfile:
n8n.yourdomain.com {
reverse_proxy localhost:5678
}
Caddy automatically provisions and renews Let's Encrypt certificates.
Step 7: Start n8n
cd /opt/n8n
docker compose up -d
Verify n8n is running:
docker compose logs -f n8n
Navigate to https://n8n.yourdomain.com to complete the initial setup.
Step 8: Configure Automated Backups
Create a backup script at /opt/n8n/backup.sh:
#!/bin/bash
DATE=$(date +%Y-%m-%d)
BACKUP_DIR=/opt/n8n/backups
mkdir -p $BACKUP_DIR
docker exec n8n-db-1 pg_dump -U n8n n8n | gzip > $BACKUP_DIR/n8n_$DATE.sql.gz
find $BACKUP_DIR -name "*.sql.gz" -mtime +30 -delete
Add to crontab to run daily at 2am:
chmod +x /opt/n8n/backup.sh
echo "0 2 * * * /opt/n8n/backup.sh" | crontab -
Production Checklist
- PostgreSQL with a strong, generated password
- Encryption key generated and backed up securely
- HTTPS via reverse proxy (Caddy or Nginx)
- Firewall allows only ports 22, 80, 443
- Automated daily database backups
- Backup restoration tested at least once
- Docker image pinned to a specific version for stability
- Unattended security updates enabled
Editor's Note: We use Hetzner CX22 (EUR 5.50/month, 2 vCPU, 4 GB RAM) for most client n8n deployments. One client has been running on this configuration for 14 months, processing approximately 2,300 executions per day across 18 active workflows, with zero unplanned downtime. The critical lesson we learned early: automated PostgreSQL backups are non-negotiable. We lost a client's 3 months of execution history before standardizing the backup script above. The database was recoverable from Docker volumes, but the incident prompted us to implement daily pg_dump backups with 30-day retention and weekly off-site sync to a separate storage service. Total monthly infrastructure cost for a production n8n instance: EUR 5.50-11.00 depending on specs.
Related Questions
Related Tools
Related Rankings
Best Human-in-the-Loop Automation Platforms 2026
Eight platforms are ranked here on a single mechanism: how a person enters an automated path, and what the system can prove afterward about the decision they made. Moxo scores 7.7 and ranks first; Camunda 8 scores 7.2, Microsoft Power Automate 7.1, Pega 6.9, n8n 6.7, Zapier 5.9, Kissflow 5.8 and ServiceNow 4.8, scored 22 September 2026 on the five weighted criteria. Those criteria cover the step type, the approver's account or licence, the routes available on a rejection, the audit record, and the meter that charges for the decision, and none of them can tell a review from a rubber stamp, so the methodology adds a check readers can run on any product in a few minutes: whether the decision record tells a considered approval from an instant one. Every figure was read from a vendor-owned surface and carries its own date.
Best Automation Platforms for AI Orchestration 2026
This ranking answers one question: how many real business applications can an AI agent act on out of the box? It evaluates nine platforms as of August 2026 on the reach they give an agent, not on the workflow logic they can express. That boundary is deliberate, because two neighbouring pages on this site answer different questions. Best Process Orchestration Platforms 2026 scores multi-step process control, error handling and state management. Best AI Agent Platforms 2026 scores building and hosting the agent itself. This page scores the layer between them: the connective tissue that lets an agent already built elsewhere reach the applications a business actually runs on. A platform that leads one of those pages can place low here, and two of them do. Scores derive from application and action catalogue counts, the exposure model each platform uses to publish those catalogues to an agent, setup effort, failure handling and cost per agent action. Every figure was retrieved from a vendor-owned surface on 11 August 2026 unless an earlier date is stated against it.
Dive Deeper
Moxo vs Lindy in 2026: Who Presses Approve When the Agent Asks
Lindy, founded in 2023, sells an AI teammate that lives in Slack and in each person's inbox; Moxo, whose predecessor Moxtra was co-founded in 2012, runs multi-party processes where approvals are steps only a person can close. Moxo wins three rounds to two: who closes the step, work across companies and the record. Lindy wins reach and testing. Vendor pages and docs read 28 September 2026.
Moxo vs Kissflow in 2026: What an Outside Approver Costs, and What the Record Proves
Moxo and Kissflow both sell approvals to people who do not write code, and each wins one round outright: Moxo's Web and Headless SDKs run the approval inside the buyer's own product, under the buyer's own sign-in. Kissflow's portal audit log stamps every event with an actor, a device and an IP, where Moxo publishes no field list. Both answers are quoted, not priced, and both meters punish a one-step request sent to hundreds of clients. Cost, the decision record, rejection routes, AI metering and governance, verified 14 to 23 September 2026.
Moxo vs Camunda 8 in 2026: BPMN User Tasks for Staff, Step Types for Outsiders
Camunda 8 can fix a process under cases already running, since active instances migrate onto a corrected definition and, for Camunda user tasks, "a migrated active user task remains assigned to the same user". Moxo keeps the shared queue that Camunda's Tasklist V2 stops evaluating, with desks that are "a shared inbox that multiple users can pick work from". Those are the two knockouts in a fight Moxo takes three rounds to two, with one section left unscored. Portability, AI review gates and a published price decide the rest, verified 14 to 23 September 2026.