DEV Community

fabrizio de luca
fabrizio de luca

Posted on

Self-Host n8n for $5/month: Complete Setup Guide (Docker + Caddy + HTTPS)

Running n8n in the cloud costs $20+/month. Running it yourself costs $4.15/month. Here's the exact setup I use.

Why Self-Host?

n8n Cloud is great but:

  • $20/month for 5 active workflows
  • $50/month for 15 workflows
  • Your data lives on their servers
  • Can't install community nodes freely

Self-hosting gives you unlimited workflows, unlimited executions, and full control — for the price of a coffee.

The Stack

  • Hetzner CX22 — €3.79/month, 2 vCPU, 4GB RAM, 40GB SSD (more than enough for n8n)
  • Docker — for easy n8n management
  • Caddy — automatic HTTPS with zero config
  • n8n — the automation engine

Step 1: Get a VPS

Best options by price:
| Provider | Spec | Price |
|---|---|---|
| Hetzner CX22 | 2 vCPU, 4GB | €3.79/mo |
| DigitalOcean Basic | 1 vCPU, 1GB | $6/mo |
| Oracle Free Tier | 4 OCPU, 24GB | Free |

I use Hetzner. Best price/performance in Europe.

After signing up, create an Ubuntu 22.04 server, add your SSH key.

Step 2: Initial Setup (5 min)

# Connect
ssh root@your-server-ip

# Update packages
apt update && apt upgrade -y

# Create non-root user
adduser n8nuser
usermod -aG sudo n8nuser

# Basic firewall
ufw allow 22/tcp
ufw allow 80/tcp  
ufw allow 443/tcp
ufw enable
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Docker (2 min)

curl -fsSL https://get.docker.com | sh
usermod -aG docker n8nuser
Enter fullscreen mode Exit fullscreen mode

Step 4: Run n8n (1 min)

docker volume create n8n_data

docker run -d   --name n8n   --restart always   -p 5678:5678   -v n8n_data:/home/node/.n8n   -e N8N_BASIC_AUTH_ACTIVE=true   -e N8N_BASIC_AUTH_USER=admin   -e N8N_BASIC_AUTH_PASSWORD=your_secure_password   -e GENERIC_TIMEZONE=Europe/Rome   -e EXECUTIONS_DATA_PRUNE=true   -e EXECUTIONS_DATA_MAX_AGE=168   n8nio/n8n
Enter fullscreen mode Exit fullscreen mode

n8n is now running on port 5678. But we need HTTPS.

Step 5: Add HTTPS with Caddy (2 min)

apt install -y caddy
Enter fullscreen mode Exit fullscreen mode

Edit /etc/caddy/Caddyfile:

n8n.yourdomain.com {
    reverse_proxy localhost:5678
}
Enter fullscreen mode Exit fullscreen mode

Point your domain's A record to your server IP, then:

systemctl restart caddy
Enter fullscreen mode Exit fullscreen mode

Caddy automatically gets and renews Let's Encrypt certificates. Your n8n is now at https://n8n.yourdomain.com with valid SSL.

Step 6: Keep It Running

# Check status
docker ps
docker logs n8n --tail 50

# Update n8n
docker pull n8nio/n8n
docker stop n8n && docker rm n8n
# run the docker run command again

# Backup (add to cron)
docker cp n8n:/home/node/.n8n ./n8n_backup_$(date +%Y%m%d)
Enter fullscreen mode Exit fullscreen mode

Step 7: Import Ready-Made Workflows

Once n8n is running, you can import workflow JSON files directly:

  1. Menu → Import from File → select .json
  2. Add your API keys in the credentials section
  3. Activate the workflow

I've packaged several production-ready workflows for free:

All free (PWYW). Just import and add your OpenAI API key.

Total Cost

Item Cost
Hetzner CX22 €3.79/month
Domain (optional) ~€1/month
OpenAI API (light usage) ~$1/month
Total ~$6/month

vs n8n Cloud at $20-50/month.


Any questions about specific steps? Comment below and I'll help you debug.

Top comments (0)