How to Self-Host n8n on a VPS in 2026
Step-by-step tutorial for self-hosting n8n on a small Linux VPS using Docker Compose, a persistent volume, HTTPS via Caddy with automatic Let's Encrypt certificates, and basic auth on the editor. Tested on a Hetzner CX22 at €4.51/month as of April 2026.
Overview
n8n is an open-source workflow automation platform that can be self-hosted on a small Linux VPS. As of April 2026 the official Docker image runs on as little as 1 GB of RAM, which puts a single-user n8n instance well within the budget of a $5/month VPS plan from providers such as Hetzner, DigitalOcean, or Vultr. This tutorial walks through a production-leaning setup using Docker Compose, a persistent volume, HTTPS via Caddy with automatic Let's Encrypt certificates, and basic auth on the editor.
The result is an n8n instance reachable at https://n8n.example.com that survives reboots, retains workflow data, and rejects unauthenticated access at the proxy layer. The same recipe scales up by changing the VPS plan; the compose file does not change.
Prerequisites
- A Linux VPS with at least 1 GB RAM and 1 vCPU (a Hetzner CX22 at €4.51/month works as of April 2026)
- Docker Engine 24.0 or newer and Docker Compose v2
- A domain name with an A record pointing at the VPS IPv4 address
- Inbound firewall rules permitting TCP ports 80 and 443
Step 1: Prepare the Server
Create a working directory and a non-root user (skip the user step if already done as part of the VPS hardening pass):
sudo mkdir -p /opt/n8n/{data,caddy-data,caddy-config}
sudo chown -R $USER:$USER /opt/n8n
cd /opt/n8n
Step 2: Generate Secrets
n8n encrypts stored credentials with N8N_ENCRYPTION_KEY. Losing this key after credentials are stored makes them unrecoverable, so back it up off-server.
cat > .env <<EOF
N8N_HOST=n8n.example.com
N8N_PROTOCOL=https
WEBHOOK_URL=https://n8n.example.com/
GENERIC_TIMEZONE=Europe/London
N8N_ENCRYPTION_KEY=$(openssl rand -hex 16)
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=$(openssl rand -hex 16)
EOF
chmod 600 .env
Step 3: Write docker-compose.yml
services:
n8n:
image: n8nio/n8n:1.85
restart: unless-stopped
environment:
- N8N_HOST
- N8N_PROTOCOL
- WEBHOOK_URL
- GENERIC_TIMEZONE
- N8N_ENCRYPTION_KEY
- N8N_BASIC_AUTH_ACTIVE
- N8N_BASIC_AUTH_USER
- N8N_BASIC_AUTH_PASSWORD
volumes:
- ./data:/home/node/.n8n
expose:
- "5678"
caddy:
image: caddy:2
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- ./caddy-data:/data
- ./caddy-config:/config
depends_on:
- n8n
Pin the n8n image to a specific minor tag rather than latest. Minor releases occasionally include database migrations that require a clean shutdown.
Step 4: Configure Caddy for HTTPS
Caddy automatically requests and renews Let's Encrypt certificates as long as DNS resolves and ports 80 and 443 are reachable.
n8n.example.com {
reverse_proxy n8n:5678
encode gzip
}
Save as /opt/n8n/Caddyfile.
Step 5: First Boot
docker compose up -d
docker compose logs -f n8n
Wait until the log shows Editor is now accessible via:. Open https://n8n.example.com in a browser. The basic-auth prompt accepts the credentials from .env. After signing in, n8n displays its own owner-setup form; complete it to register the first internal user.
Step 6: Backups
Workflow data lives entirely in /opt/n8n/data. A nightly backup is enough for low-volume single-user use:
0 3 * * * tar czf /var/backups/n8n-$(date +\%F).tgz /opt/n8n/data /opt/n8n/.env
Copy the resulting archives off-server (rsync, S3, restic). The .env file is included because the encryption key is required to decrypt restored credentials.
Step 7: Updating n8n
To upgrade, edit the image tag in docker-compose.yml, then:
docker compose pull
docker compose up -d
docker compose logs -f n8n
Read the n8n changelog before crossing minor versions. Major version bumps (for example 1.x to 2.x) sometimes require a manual migration step.
Common Issues
- Caddy fails to issue a certificate. DNS has not propagated, or port 80 is blocked. Run
dig n8n.example.comandcurl http://n8n.example.comfrom another machine. Editor is now accessible via http://localhost:5678and webhooks fail.WEBHOOK_URLis missing. Set it to the public HTTPS URL.- Workflows pause after restart. Free RAM is exhausted. Upgrade the VPS to 2 GB or move to queue mode with PostgreSQL and Redis.
For higher-throughput deployments, see the related guide on running n8n with a dedicated PostgreSQL backend and the n8n vs ActivePieces comparison for context on alternative open-source platforms. The n8n tool page tracks current pricing for the n8n Cloud option.
Editor's Note: We run roughly a dozen client n8n instances on Hetzner CX22 boxes (€4.51/month, 4 GB RAM as of April 2026) and have not yet hit a CPU ceiling on single-tenant workloads under 5,000 executions per day. The single most expensive mistake we made early on was not backing up the encryption key off-server; one VPS rebuild silently invalidated about 40 stored credentials. Backups now include
.envby default.
Tools Mentioned
Related Guides
Moxo vs Gumloop in 2026: Texting the Client, or Building the Agent
Gumloop (founded 2023) builds AI agents a company's own staff run; Moxo, whose predecessor Moxtra was co-founded in 2012, runs processes that wait on people outside the company. Gumloop wins three rounds to two: the way in, per-tool gating and a priced overage. Moxo wins on…
Moxo vs Relay.app in 2026: Where Relay's Approval Workflows Can Go Next
Relay.app, founded in 2021, shut down in September 2026 and deleted every account, workflow and run history; Moxo, whose predecessor Moxtra was co-founded in 2012, is one destination for its human-in-the-loop users. Relay.app takes two rounds, Moxo one, and vendor risk is a draw…
Moxo vs Workato in 2026: The Integration Estate, or the Approval Inside It
Workato, founded in 2013, is an enterprise integration platform whose Workflow apps add human tasks to recipes; Moxo, whose predecessor Moxtra was co-founded in 2012, ships the human step itself. Workato wins three rounds to two: connector reach, change control and the way in…
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…
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…
Common Questions
How do banks and wealth firms use Moxo for client onboarding?
Moxo's financial-services page (read 13 October 2026) pitches account opening and KYC reviews as shared work: the client gets a secure link to see what is needed and sign, while relationship managers, compliance and operations staff review and approve inside one tracked flow. The…
Can healthcare teams run patient-facing workflows on Moxo?
Yes for coordination work, once a signed BAA is in hand: Moxo told Automation Atlas in writing on 6 October 2026 that it signs BAAs, but it publishes none and did not say which plans the agreement covers or whether it reaches Moxo AI. Moxo says it has no native EHR, HL7 or FHIR…
Who is accountable when an AI agent acts in a Moxo workflow?
The company that deploys the agent is accountable: Moxo's Terms and Conditions (read 13 October 2026) make the customer "solely responsible for any AI Content, including the accuracy, quality, appropriateness, and legality thereof". In the workflow, a named person owns each human…
How does Moxo keep humans in control when AI agents run a workflow?
Moxo keeps people on the decisions by design: approvals and other human steps are ones its product page says "only a person can close", and AI agents can fill preparer, advisor or reviewer slots around them (both read 15 September 2026). The checks on AI output are opt-in…