21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

Install n8n on a VPS

Quick answer

To install n8n on a VPS, install Docker with its Compose plugin, write a compose file that pins the image, binds port 5678 to localhost and mounts /home/node/.n8n as a volume, then put Nginx with a Certbot certificate in front. It works when the editor opens over HTTPS and a test webhook reaches it.

For developers and operations teams self-hosting n8n workflow automation on their own Ubuntu VPS.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
5 min
Sections
8
Updated
14 Nov 2026
Written by
WebJi® team

What does a VPS need to run n8n?

n8n runs comfortably on a Linux VPS with Docker, 2 vCPU, 2–4 GB RAM, 20–40 GB of disk and a DNS name pointed at the server. RAM is the limit you hit first, because Node.js, the database and execution history share it.

n8n server sizing
ResourceMinimumComfortableWhat pushes it up
RAM2 GB4 GB+Postgres on the same box, large payloads, many active workflows
vCPU12+Code and HTTP Request nodes, concurrent executions
Disk20 GB40 GB+ NVMeExecution history and binary data
OSUbuntu 22.04Ubuntu 24.04 LTSDocker's install script supports both
DNSOne A recordPlus a staging subdomainWebhook URLs are built from the hostname

Point the A record (for example n8n.example.in) at the server before starting the container, because n8n registers webhook URLs from that hostname. WebJi® VPS hosting starts from ₹499 a month before 18% GST, with the 2 vCPU / 4 GB VPS-Start sample quoted in INR.

How do you install Docker and secure the ports?

Install Docker Engine with its Compose plugin from Docker's official script, then allow only SSH, HTTP and HTTPS through the firewall and keep port 5678 bound to localhost. The editor should be reachable only through Nginx.

sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com | sudo sh
docker --version && docker compose version   # Compose v2 plugin

sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable

Docker writes its own iptables rules, so a port published as 5678:5678 can bypass UFW. Binding it to 127.0.0.1, as in the compose file below, avoids that. The firewall guide explains the issue.

What should the n8n docker-compose file contain?

A pinned image tag, a restart policy, a loopback-only port, a named volume at /home/node/.n8n, and environment values for the hostname, protocol, webhook URL, timezone and a fixed encryption key. The volume and the key are what make backups restorable.

# /opt/n8n/docker-compose.yml
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n:PINNED_VERSION   # replace with a release tag
    restart: unless-stopped
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      - N8N_HOST=n8n.example.in
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.example.in/
      - N8N_PROXY_HOPS=1
      - GENERIC_TIMEZONE=Asia/Kolkata
      - TZ=Asia/Kolkata
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
    volumes:
      - n8n_data:/home/node/.n8n
volumes:
  n8n_data:
# /opt/n8n/.env  (keep a copy of this key with your backups)
N8N_ENCRYPTION_KEY=paste-a-long-random-string-here

cd /opt/n8n && docker compose up -d && docker compose logs -f n8n

Generate the key with openssl rand -hex 32. Without the same key, a restored volume cannot decrypt saved credentials.

How do you put Nginx and HTTPS in front of n8n?

Add an Nginx server block that proxies your hostname to 127.0.0.1:5678 with WebSocket upgrade headers, then run Certbot to issue and install a Let's Encrypt certificate. Most services that call webhooks require HTTPS.

# /etc/nginx/sites-available/n8n
server {
    listen 80;
    server_name n8n.example.in;
    client_max_body_size 16m;

    location / {
        proxy_pass http://127.0.0.1:5678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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_buffering off;
    }
}

sudo apt install -y nginx certbot python3-certbot-nginx
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d n8n.example.in --redirect

The install is finished when https://n8n.example.in shows the padlock and the owner-account setup screen. Certbot details are in the Certbot and Nginx SSL guide.

Why do n8n webhooks return 404?

A 404 from a self-hosted n8n webhook usually means the workflow is not active, the test URL was called while the editor was not listening, or WEBHOOK_URL does not match the hostname being called. It is rarely the firewall.

  • Production vs test: production URLs (/webhook/…) exist only while the workflow is active; test URLs (/webhook-test/…) only while you click "Listen".
  • Changed hostname: after editing WEBHOOK_URL, recreate the container with docker compose up -d.
  • Proxy headers: a missing X-Forwarded-Proto makes n8n build http:// links.
  • Test from outside: curl -i https://n8n.example.in/webhook/your-path. A 404 is n8n routing; a timeout is DNS or firewall.

How do you back up and update n8n safely?

Back up the named volume and the encryption key together, and update by changing the pinned image tag, pulling and recreating the container after reading the release notes. Never update by running latest blindly.

# back up the volume to the current folder
docker run --rm -v n8n_n8n_data:/data -v "$(pwd)":/backup alpine \
  tar czf /backup/n8n-data-$(date +%F).tar.gz -C /data .

# update after editing the image tag
docker compose pull && docker compose up -d

Compose prefixes the volume with the project folder name, so a project in /opt/n8n creates n8n_n8n_data; check with docker volume ls. Copy the archive and the .env file off the server. Major versions can rename settings or change node behaviour, so keep the previous tag noted for rollback.

When does an n8n server need more resources?

Executions queuing, the container restarting after out-of-memory kills, and a slow editor during busy periods are the signs; move to Postgres for multi-user instances and to queue mode with Redis workers when one process cannot keep up.

Check docker stats during busy hours and sudo dmesg -T | grep -i oom after an unexpected restart. SQLite, n8n's default database, can lock under heavy concurrent writes; Postgres removes that limit. Both changes are compose edits, so a VPS can be resized rather than rebuilt; see how much RAM a VPS needs. If you prefer not to run it yourself, the n8n hosting page quotes a server set up for n8n; email support@webji.services, answered 24/7 in Hindi and English.

FAQ

Frequently asked questions

Is self-hosted n8n free for business use?

The Community Edition can be self-hosted for your own internal workflows under n8n's Sustainable Use License. Offering n8n itself as a paid service to others, or using enterprise features such as SSO, needs a commercial licence; read the current licence terms before building a product on it.

Should I install n8n with npm instead of Docker?

Docker is simpler on a server: the image includes the right Node.js version, the restart policy keeps it running, and updates are a tag change. An npm install needs a matching Node version and your own service manager such as systemd or PM2.

Can I run n8n on shared hosting?

Generally no. n8n needs a long-running Node.js process and usually Docker, which shared hosting accounts do not provide. A small VPS with root access is the practical minimum.

How do I connect n8n to WhatsApp or Google Sheets from India?

Use n8n's built-in nodes with credentials from each service: a WhatsApp Business Platform account for WhatsApp, and a Google Cloud OAuth client for Sheets. Both need your public HTTPS URL as a callback or webhook address.

Configuration checked against n8n's Docker and reverse-proxy documentation · Reviewed by the WebJi® team, Jaipur.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.