Self Host n8n on a $5 VPS: Step-by-Step Guide

n8n is free and open-source, but the official cloud plan gets expensive once your executions grow. The good news: you can self host n8n on a cheap VPS for a few dollars a month and run unlimited workflows with full control over your data. In this step-by-step guide, you'll deploy n8n on a $5 VPS using Docker, put it behind HTTPS, and keep it running reliably.

Total time: about 30 minutes. You need a VPS with at least 1 GB of RAM and a domain or subdomain pointing at the server's IP (for HTTPS).

Why Self Host n8n on a VPS?

Self-hosting n8n gives you three big advantages over the managed cloud:

  • Cost. n8n Cloud's paid tiers start around $20/month and scale with executions. A $5 VPS handles thousands of executions monthly for a flat price.
  • Privacy. Your credentials and workflow data never leave your server — important if you automate client or business data.
  • Control. Install community nodes, run custom code, mount volumes, and tune the queue mode however you like.

If you don't have a VPS yet, check our roundup of best VPS providers with open port 25 — several budget options work great for n8n. Providers like Contabo offer generous RAM at the $5 price point, which n8n appreciates.

Self-Hosted n8n vs n8n Cloud: The Cost Math

To see why so many people choose to self host n8n, run the numbers. n8n Cloud's Starter plan covers a limited number of monthly executions, and costs climb quickly once you add active workflows with frequent triggers. A single workflow that polls an API every minute burns over 43,000 executions a month by itself.

On a $5 VPS, executions are effectively unlimited — your only constraint is server resources. Webhook-triggered workflows (which don't poll) can run hundreds of thousands of executions monthly on 1–2 GB of RAM without breaking a sweat. The trade-off is your time: you handle updates, backups, and uptime. For most technical users, 30 minutes of setup plus a weekly update cron is a very good deal compared to a growing SaaS bill.

Step 1: Prepare the VPS

Spin up an Ubuntu 24.04 VPS and SSH in. Update the system and install Docker:

sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

Log out and back in so the docker group takes effect, then create a working directory:

mkdir -p ~/n8n && cd ~/n8n

Step 2: Configure n8n with Docker Compose

Create a docker-compose.yml file. This setup uses SQLite (fine for getting started) and exposes n8n on port 5678:

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=n8n.yourdomain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.yourdomain.com/
      - GENERIC_TIMEZONE=Asia/Kolkata
      - N8N_ENCRYPTION_KEY=replace-with-a-long-random-string
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Set N8N_ENCRYPTION_KEY to a long random value (generate one with openssl rand -hex 32) and keep it safe — losing it means losing access to stored credentials. The WEBHOOK_URL variable is critical: without it, webhook trigger URLs will be wrong.

Start n8n:

docker compose up -d
docker compose logs -f n8n

Wait for “Editor is now accessible” in the logs, then open http://your-server-ip:5678 to confirm it's running.

Step 3: Add HTTPS with a Reverse Proxy

Running n8n over plain HTTP is a security risk — your login and webhook data travel unencrypted. Install Nginx and Certbot:

sudo apt install -y nginx certbot python3-certbot-nginx

Point your subdomain (e.g. n8n.yourdomain.com) at the VPS IP in DNS, then create an Nginx site:

sudo nano /etc/nginx/sites-available/n8n
server {
    listen 80;
    server_name n8n.yourdomain.com;

    location / {
        proxy_pass http://localhost: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_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Enable it and get a free Let's Encrypt certificate:

sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d n8n.yourdomain.com

Now open https://n8n.yourdomain.com — you should see the n8n setup screen over HTTPS. Create your owner account.

Step 4: Harden and Maintain Your Instance

A few things that separate a hobby install from a reliable one:

  • Enable the firewall. sudo ufw allow 22,80,443/tcp && sudo ufw enable — block everything else, including direct access to port 5678.
  • Set up automatic updates. Watchtower or a weekly cron running docker compose pull && docker compose up -d keeps n8n patched.
  • Back up the volume. A nightly docker run --rm -v n8n_n8n_data:/data -v ~/backups:/backup busybox tar czf /backup/n8n-$(date +%F).tar.gz /data plus off-site copy protects your workflows and credentials.
  • Switch to Postgres later. If you outgrow SQLite (heavy queue-mode usage), migrate the database — n8n documents the export/import path.

Troubleshooting Common Issues

  • Webhooks return 404: the WEBHOOK_URL env var doesn't match your public URL, or the workflow isn't active. Check both.
  • “Lost connection” in the editor: the WebSocket upgrade headers are missing in Nginx — make sure the Upgrade/Connection lines are present.
  • High memory usage: n8n likes RAM. If workflows stall on a 1 GB VPS, upgrade to 2 GB — Contabo and OVH both have affordable 2 GB tiers.

Key Takeaways

  • You can self host n8n on a $5 VPS with Docker in about 30 minutes.
  • Always set WEBHOOK_URL and N8N_ENCRYPTION_KEY before first launch.
  • Put n8n behind Nginx with a Let's Encrypt certificate — never expose it over plain HTTP.
  • Enable UFW, automate updates, and back up the data volume nightly.
  • A 1 GB VPS works to start; move to 2 GB+ as your workflow count grows.

Related Guides

Leave a Comment Cancel reply

Exit mobile version