Male tech professional setting up n8n automation on a VPS with Docker, SSL, and Nginx

How to Self-Host n8n on a VPS – Step-by-Step Setup Guide

Self-hosting n8n on a VPS is one of the smartest moves if you want reliable automations that run 24/7 — without depending on costly “per-task” cloud plans.

With a VPS, you get:

  • Full control over your workflows
  • Better stability for scheduled automations
  • Ability to scale over time (more workflows, more integrations)
  • Your own secure environment (especially important for API keys)

This guide walks you through a clean, beginner-friendly setup using Docker + Nginx + SSL, which is the most popular approach for stable n8n self-hosting.

TL;DR (Quick Summary)

  • Buy a VPS (2GB+ RAM recommended for smooth usage)
  • Point a domain/subdomain to the VPS
  • Install Docker + Docker Compose
  • Run n8n with persistent storage
  • Add Nginx reverse proxy + free SSL (Let’s Encrypt)
  • Secure it with basic firewall + updates

Why Self-Host n8n Instead of Using n8n Cloud?

Self-hosting is best if you:

  • Run many workflows daily
  • Need reliable uptime for scheduled tasks
  • Want to store data privately
  • Plan to scale automations for months/years

n8n Cloud is easier at the beginning, but self-hosting is typically more cost-efficient as your automations grow.

What You Need Before You Start

✅ Minimum VPS Requirements (Recommended)

  • RAM: 2GB minimum (4GB ideal if you plan to run many workflows)
  • CPU: 1–2 vCPU
  • Storage: 30GB+
  • OS: Ubuntu 22.04 LTS (recommended)

✅ Domain / Subdomain

Examples:

  • n8n.domainreview.tech
  • automation.domainreview.tech

✅ A VPS Provider

If you want a beginner-friendly VPS option with good value:

👉 Get a Reliable VPS for n8n Automation (Recommended): 👉 Get a Reliable VPS for n8n Automation (Recommended

Step 1: Create Your VPS + Login via SSH

  1. Buy VPS and choose Ubuntu 22.04
  2. Copy your server IP + root password (or SSH key)
  3. Connect via SSH:

Windows (PowerShell):

ssh root@YOUR_SERVER_IP

If using password:
Enter the password when prompted.

Step 2: Update Your Server (Important)

Run:

apt update && apt upgrade -y

Install basic tools:

apt install -y curl nano ufw

Step 3: Setup Firewall (UFW)

Allow SSH, HTTP, HTTPS:

ufw allow OpenSSH
ufw allow 80
ufw allow 443
ufw enable

Check status:

ufw status

Step 4: Install Docker + Docker Compose

Install Docker:

curl -fsSL https://get.docker.com | sh

Install Docker Compose plugin:

apt install -y docker-compose-plugin

Verify:

docker --version
docker compose version

Step 5: Create a Folder for n8n

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

Step 6: Create Docker Compose File (Persistent Data)

Create the file:

nano docker-compose.yml

Paste this:

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/
      - GENERIC_TIMEZONE=America/Toronto
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

✅ Replace:

  • n8n.yourdomain.com with your real subdomain
  • timezone if needed

Start n8n:

docker compose up -d

Check status:

docker ps

Step 7: Point Your Domain to the VPS

In your domain DNS settings:

  • Add an A record
  • Name: n8n (or automation)
  • Value: YOUR_SERVER_IP

Wait 5–30 minutes for DNS propagation.

Step 8: Add Nginx Reverse Proxy

Install Nginx:

apt install -y nginx

Create config file:

nano /etc/nginx/sites-available/n8n

Paste (replace domain):

server {
  server_name n8n.yourdomain.com;

  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;
  }
}

Enable it:

ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

Step 9: Install Free SSL Certificate (Let’s Encrypt)

Install Certbot:

apt install -y certbot python3-certbot-nginx

Run SSL:

certbot --nginx -d n8n.yourdomain.com

Follow prompts and enable redirect to HTTPS.

Test auto renewal:

certbot renew --dry-run

Step 10: Secure n8n (Best Practices)

✅ Add Basic Auth (Optional but Recommended)

n8n supports user authentication and secure access. Use strong password and avoid exposing admin to public without protection.

✅ Use backups

Backup the volume:

  • n8n credentials, workflows stored in /home/node/.n8n

✅ Keep your server updated

Run weekly:

apt update && apt upgrade -y

Troubleshooting (Quick Fixes)

n8n not loading?

  • Check docker:
docker logs -f n8n

DNS not working?

  • Confirm A record points to correct IP
  • Wait longer, flush DNS cache

SSL fails?

  • Make sure your domain points to server IP
  • Ports 80/443 open
  • Nginx config correct

Best VPS Tips for Stable Automations

If you plan to run:

  • WordPress automation
  • daily affiliate posting
  • Telegram alerts
  • scheduled workflows

Then 2GB RAM is minimum, 4GB RAM is ideal.

Recommended VPS for Automation

If you plan to self-host n8n or run scheduled workflows 24/7, use a fast and reliable VPS with at least 2GB RAM (4GB ideal).

👉 Start with a Fast VPS for n8n (Best Value in 2025)

You may also explore these helpful categories:

Affiliate disclosure: Some links in this article are affiliate links. If you purchase through these links, I may earn a commission at no extra cost to you.