Skip to content
ZeeGrowth logozeegrowth
Self-hosting·

How to Self-Host n8n on a $5 VPS (Step by Step)

M
Mohammad Sayyaf

Founder, ZeeGrowth

Why self-host n8n?

Self-hosting n8n gives you three things: full control over your data, no per-execution costs, and the ability to run as many workflows as your server can handle. For most small businesses, a $5-10/month VPS is more than enough.

What you need

  • A VPS from DigitalOcean, Hetzner, or any provider ($5-10/month, 1 vCPU, 2 GB RAM minimum)
  • A domain name pointed to your server IP address
  • Basic comfort with a terminal (copy-paste level is fine)
  • About 30 minutes

Step 1: Provision your server

Sign up with a VPS provider and create a server with these specs: Ubuntu 22.04 or 24.04 LTS, 2 GB RAM minimum (4 GB recommended for AI workflows), 20 GB SSD. Note the server IP address.

Step 2: Point your domain

Add an A record in your DNS provider pointing your chosen subdomain (e.g. n8n.yourdomain.com) to your server IP. Wait a few minutes for DNS propagation.

Step 3: Connect and install Docker

SSH into your server and install Docker:


ssh root@YOUR_SERVER_IP
apt update && apt upgrade -y
curl -fsSL https://get.docker.com | sh
apt install docker-compose-plugin -y

Step 4: Create the n8n configuration

Create a directory and Docker Compose file:


mkdir -p /opt/n8n && cd /opt/n8n

Your docker-compose.yml should include the n8n image, port 5678 mapping, environment variables for your domain and timezone, and a named volume for persistent data.

Key environment variables: N8N_HOST (your domain), N8N_PROTOCOL (https), WEBHOOK_URL (your full https URL), and N8N_ENCRYPTION_KEY (a strong random string you generate once and never change).

Step 5: Set up a reverse proxy with SSL

Install Caddy as a reverse proxy. Caddy handles SSL certificates automatically via Let's Encrypt:


apt install caddy

Configure Caddy to reverse proxy to localhost:5678 for your domain. Caddy automatically provisions and renews certificates.

Step 6: Start n8n


cd /opt/n8n
docker compose up -d

Open your domain in a browser. You should see the n8n setup screen. Create your admin account and you are in.

Step 7: Set up backups

Create a backup script that exports all workflows and saves them to a dated directory. Schedule it with cron to run nightly at 2 AM. Store backups locally and optionally sync to cloud storage.

Step 8: Updating n8n

Pull the latest image and restart:


cd /opt/n8n
docker compose pull
docker compose up -d

Always check the n8n changelog before updating to review breaking changes.

Costs breakdown

A basic setup costs $5-10/month for the VPS, about $1/month averaged for a domain, and nothing for SSL (Caddy plus Let's Encrypt). Total: $6-14/month compared to $24+/month for n8n Cloud or $30+/month for Zapier.

Security essentials

  • Enable a firewall allowing only SSH, HTTP and HTTPS
  • Use SSH keys instead of passwords
  • Keep your server and Docker images updated
  • Set a strong N8N_ENCRYPTION_KEY (never change it after setup)
  • Consider adding IP restrictions for extra protection

Next steps

Your self-hosted n8n is ready to run. Start by importing a few free templates to test your setup, then build your own workflows. If you would rather have someone handle the hosting, check our managed hosting service.

Related templates

Want us to set it up for you?

We install the workflow on your n8n instance, connect credentials, and leave you with a running automation.

Get setup help

Free n8n automations that grow your business.