How to Self-Host n8n for $5/Month
Zapier charges $299/month for what n8n does — and n8n can run on a $5 VPS. If you’re technical enough to deploy your own server, the economics are a no-brainer. Here’s how to do it properly.
## Why Self-Host n8n?
The cloud version of n8n is $19/month for the Starter plan. The self-hosted version is free (open-source). A $5 VPS from Oracle, Hetzner, or RackNerd gives you full control, your own data, and no vendor lock-in.
The tradeoff: you manage the server. But for most use cases, n8n is lightweight enough that a $5 VPS handles it easily.
## What You’ll Need
– A VPS with at least 2GB RAM (n8n needs ~800MB just to start)
– Ubuntu 22.04 (the officially supported option)
– A domain name pointed to your VPS (optional but recommended)
– 30 minutes
## Step 1: Set Up the VPS
“`bash
SSH into your VPS
ssh root@your-vps-ip
Create a non-root user
adduser n8n
usermod -aG sudo n8n
Update the system
sudo apt update && sudo apt upgrade -y
“`
## Step 2: Install Docker
“`bash
Install Docker
curl -fsSL https://get.docker.com | sudo sh
Enable and start Docker
sudo systemctl enable docker
sudo systemctl start docker
Add n8n user to docker group
sudo usermod -aG docker n8n
“`
## Step 3: Deploy n8n via Docker Compose
Create `/home/n8n/docker-compose.yml`:
“`yaml
version: ‘3.8’
services:
n8n:
image: n8nio/n8n:latest
restart: always
ports:
– “5678:5678”
environment:
– N8N_HOST=n8n.yourdomain.com
– N8N_PORT=5678
– N8N_PROTOCOL=https
– WEBHOOK_URL=https://n8n.yourdomain.com/
– N8N_SECURE_COOKIE=false
– EXECUTIONS_DATA_PRUNE=true
– GENERIC_TIMEZONE=Asia/Shanghai
volumes:
– n8n_data:/home/n8n/.n8n
networks:
– n8n-net
volumes:
n8n_data:
driver: local
networks:
n8n-net:
driver: bridge
“`
“`bash
cd /home/n8n
docker-compose up -d
“`
## Step 4: SSL with Nginx Reverse Proxy
If you want HTTPS (and you should), set up Nginx as a reverse proxy and get a free Let’s Encrypt cert:
“`bash
sudo apt install nginx certbot python3-certbot-nginx -y
sudo certbot –nginx -d n8n.yourdomain.com
“`
Then configure Nginx:
“`nginx
server {
listen 443 ssl;
server_name n8n.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_buffering off;
}
}
“`
## Step 5: Harden Your Setup
Change the default credentials:
“`bash
docker exec n8n n8n user-management:reset
“`
Enable basic auth:
“`bash
Add to docker-compose.yml environment:
– N8N_BASIC_AUTH_ACTIVE=true
– N8N_BASIC_AUTH_USER=admin
– N8N_BASIC_AUTH_PASSWORD=your-strong-password
“`
Set up a firewall:
“`bash
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw allow 80/tcp
sudo ufw enable
“`
## Step 6: Enable Auto-Restart on Failure
Update the docker-compose.yml `restart` policy:
“`yaml
restart: always
“`
Docker will automatically restart n8n if the container crashes. For the VPS itself, set up a watchdog cron:
“`bash
Check if n8n is running every 5 minutes
/5 * docker ps | grep -q n8n || (cd /home/n8n && docker-compose up -d)
“`
## Maintenance
| Task | Frequency | Command |
| :— | :— | :— |
| Update n8n | Monthly | `cd /home/n8n && docker-compose pull && docker-compose up -d` |
| Backup data | Weekly | `rsync -av /home/n8n/.n8n /backup/n8n/` |
| View logs | Anytime | `docker logs n8n_n8n_1 -f` |
| Check disk | Weekly | `df -h` |
## Performance Notes
n8n is surprisingly lightweight. On a $5 VPS (1 vCPU, 2GB RAM):
– 10 active workflows → ~800MB RAM
– 100+ executions/day → < 5% CPU
– Fine for personal use and small agency operations
For heavy workloads (hundreds of executions/hour, large data volumes), upgrade to 4GB+ RAM.
## Conclusion
Self-hosting n8n is one of the highest-ROI technical decisions you can make. The cost difference between cloud and self-hosted is $19/month × 12 = $228/year. On a $5 VPS, you break even in month 1.
The setup takes 30-45 minutes. After that, you have a permanently free automation engine that you control completely.
—
Related reading:
– OpenClaw Docker Setup: 30 Minutes
– Self-Hosted AI Stack: Ollama + n8n
Related Articles
Get Notified About New Articles
One email per week when I publish a new article or update an existing one. New AI tool reviews, deployment updates, behind-the-scenes notes. No marketing, no spam, unsubscribe in one click.
Or learn more · RSS feed
- How to Set Up Claude Code with the MiniMax API in 2026
- How to Set Up Hermes Web UI for AI Agent Management in 2026
- OpenClaw vs ChatGPT: Why Self-Hosting Wins for Power Users in 2026
- OpenClaw Docker Setup: From Zero to Running AI Assistant in 30 Minutes
Get Notified About New Articles
One email per week when I publish a new article or update an existing one. No marketing, no spam.