2026-06-07
How to Self-Host n8n on a $5 VPS (Complete 2026 Guide)
Step-by-step guide to self-hosting n8n on a cheap VPS. Covers Hetzner, DigitalOcean, Docker setup, SSL with Caddy, automated backups, and monitoring — all for $5/month. Run unlimited workflows with zero recurring automation costs.
How to Self-Host n8n on a $5 VPS (Complete 2026 Guide)
Self-hosting n8n is the single highest-ROI move you can make in workflow automation. For $5/month — less than a coffee subscription — you get unlimited workflows, unlimited executions, and complete data privacy. No per-task pricing. No vendor lock-in. No one else touching your data.
I've set up n8n on a dozen VPS instances and condensed everything I've learned into this guide. By the end, you'll have a production-ready n8n instance with SSL, automatic backups, and monitoring — in about 30 minutes.
Why Self-Host?
| | n8n Cloud (Starter) | n8n Cloud (Pro) | Self-Hosted | |---|---|---|---| | Monthly cost | $20 | $50 | $5 | | Workflows | Unlimited | Unlimited | Unlimited | | Executions | 5,000/mo | 50,000/mo | Unlimited | | Data location | n8n servers | n8n servers | Your server | | Custom nodes | Yes | Yes | Yes | | GDPR compliance | DPA required | DPA required | Default |
The math is simple: if you run more than ~2,500 tasks/month, self-hosting pays for itself in month one. And you keep your data on your own infrastructure — critical for GDPR, HIPAA, or any sensitive business data.
Step 1: Pick Your VPS
These are the best $5/month options as of 2026:
| Provider | Plan | RAM | CPU | Storage | Location | |---|---|---|---|---|---| | Hetzner CX22 | €4.49/mo | 4 GB | 2 vCPU | 40 GB | EU/US | | DigitalOcean | $6/mo | 1 GB | 1 vCPU | 25 GB | Global | | Vultr | $6/mo | 1 GB | 1 vCPU | 25 GB | Global | | Akamai/Linode | $5/mo | 1 GB | 1 vCPU | 25 GB | Global |
My pick: Hetzner CX22. 4 GB RAM for ~$5 is unbeatable. n8n runs comfortably on 1 GB, but 4 GB gives you room to add PostgreSQL, Redis, and other services later. Plus Hetzner has data centers in Germany, Finland, and Virginia (US).
Spin up a VPS with Ubuntu 24.04 LTS (or the latest LTS available).
Step 2: Initial Server Setup
SSH into your fresh server:
ssh root@YOUR_SERVER_IP
Update the system and create a non-root user:
apt update && apt upgrade -y
adduser n8n
usermod -aG sudo n8n
su - n8n
Set up the firewall:
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Step 3: Install Docker
Docker is the cleanest way to run n8n — isolated, reproducible, and easy to upgrade.
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
newgrp docker
# Verify
docker --version
Install Docker Compose (standalone plugin):
sudo apt install docker-compose-plugin -y
Step 4: Deploy n8n with Docker Compose
Create a directory and compose file:
mkdir ~/n8n && cd ~/n8n
nano docker-compose.yml
Paste this production-ready configuration:
version: '3.8'
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_HOST=n8n.yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://n8n.yourdomain.com/
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- DB_TYPE=sqlite
- N8N_USER_FOLDER=/home/node/.n8n
volumes:
- n8n_data:/home/node/.n8n
- ./backups:/backups
networks:
- n8n_network
volumes:
n8n_data:
networks:
n8n_network:
driver: bridge
Important: Replace n8n.yourdomain.com with your actual domain. You need a domain pointing to your server's IP (A record).
Generate an encryption key:
openssl rand -hex 32
Add it to a .env file:
echo "N8N_ENCRYPTION_KEY=your-generated-key-here" > .env
Start n8n:
docker compose up -d
n8n is now running on port 5678. But we need SSL.
Step 5: SSL with Caddy (Automatic HTTPS)
Caddy is the simplest reverse proxy with built-in TLS certificate automation. Create a Caddyfile:
mkdir ~/caddy && cd ~/caddy
nano Caddyfile
n8n.yourdomain.com {
reverse_proxy localhost:5678
}
Create a compose file for Caddy:
nano docker-compose.yml
version: '3.8'
services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
networks:
- n8n_network
volumes:
caddy_data:
caddy_config:
networks:
n8n_network:
external: true
Start Caddy:
docker compose up -d
Wait 30 seconds and visit https://n8n.yourdomain.com. You should see the n8n login screen. SSL certificate is automatically provisioned.
Step 6: Create Your Admin Account
Visit your n8n instance and create an owner account. Use a strong password.
Pro tip: Enable MFA (multi-factor authentication) under Settings → Personal → Two-Factor Authentication. It takes 2 minutes and dramatically improves security.
Step 7: Automated Backups
Create a backup script at ~/n8n/backup.sh:
#!/bin/bash
BACKUP_DIR="/home/n8n/n8n/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="$BACKUP_DIR/n8n_backup_$TIMESTAMP.tar.gz"
# Stop n8n briefly for consistent backup
docker compose -f /home/n8n/n8n/docker-compose.yml stop
tar -czf "$BACKUP_FILE" /var/lib/docker/volumes/n8n_n8n_data/_data/
docker compose -f /home/n8n/n8n/docker-compose.yml start
# Keep only last 7 daily backups
ls -t "$BACKUP_DIR"/n8n_backup_*.tar.gz | tail -n +8 | xargs -r rm
echo "Backup complete: $BACKUP_FILE"
Make it executable and add to crontab:
chmod +x ~/n8n/backup.sh
(crontab -l 2>/dev/null; echo "0 3 * * * /home/n8n/n8n/backup.sh >> /home/n8n/n8n/backups/backup.log 2>&1") | crontab -
This backs up nightly at 3 AM and keeps 7 days of history.
For off-server backups, add this to the script — upload to S3, Backblaze B2, or any cloud storage using rclone or aws-cli.
Step 8: Monitoring & Updates
Check that n8n is running:
docker ps | grep n8n
View logs:
docker compose -f ~/n8n/docker-compose.yml logs -f --tail=100
Update n8n:
cd ~/n8n
docker compose pull # pull latest image
docker compose up -d # recreate container with new image
docker image prune -f # clean up old images
Optional: Uptime monitoring. Use a free cron monitoring service like healthchecks.io or UptimeRobot to ping your n8n instance and alert you if it goes down. Better yet — create an n8n workflow that monitors itself!
Step 9: Performance Tuning
For production use, switch from SQLite to PostgreSQL. SQLite works fine for a few hundred workflows but can slow down with high concurrency.
Add PostgreSQL to your docker-compose.yml:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=strong_password_here
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- n8n_network
Update n8n environment variables:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=strong_password_here
Add 1 GB swap for extra headroom on small VPS:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Total Cost Breakdown
| Item | Monthly Cost | |---|---| | Hetzner CX22 VPS | $4.90 | | Domain name (~$12/yr) | $1.00 | | Backups (Backblaze B2 ~$0.005/GB) | $0.10 | | Total | $6.00/month |
For $6/month you get: unlimited workflows, unlimited executions, full data privacy, custom code nodes, and 400+ integrations. Compare that to Zapier's $299/month for 100,000 tasks. It's not even close.
What's Next?
Now that n8n is running, import a few templates to get started fast:
- Web Form → Google Sheets + Email — capture form submissions automatically
- Stripe Payment → Invoice Email — automate your billing
- RSS → Daily Email Digest — stay on top of your industry
All 25 FlowForge templates work perfectly on your new self-hosted instance — import the JSON and run in under 10 minutes.
Got stuck? Drop a comment or check the n8n community forum. The self-hosting community is active and helpful.
Ready to automate?
Browse 25+ production-ready n8n templates. Import, configure, and run — all in under 10 minutes.
Browse Templates