Back to articles
Cloud AutomationAvertHostNovember 22, 20269 min read

n8n VPS Hosting: Self-Host n8n with Docker and HTTPS in India

How to self-host n8n on an Ubuntu cloud VPS with Docker Compose, PostgreSQL, Nginx HTTPS, backups and India-specific points on DPDP, time zone and INR billing.

n8n VPS hosting means running the n8n workflow automation tool in Docker on a Linux server you control, behind Nginx with HTTPS, so your workflows run around the clock and your data stays on your own infrastructure. A small cloud VPS with 2 vCPU and 2 to 4 GB of RAM is enough for light and moderate workloads. This guide covers sizing, a Docker Compose setup with PostgreSQL, the reverse proxy, backups and the India-specific points to check before you automate anything that touches customer data.

The steps assume a fresh Ubuntu 22.04 or 24.04 server. If it is not prepared yet, do the first 30 minutes of VPS setup first (non-root user, SSH keys, firewall).

Why self-host n8n on a VPS

n8n can be used as a paid hosted service or installed on your own server. Self-hosting on a cloud VPS makes sense when:

  • Executions add up. Hosted plans are priced around workflow executions. On your own server the limit is CPU, RAM and disk, which you control.
  • Data must stay in India. Workflows often move customer records, invoices or WhatsApp and email content between tools. Running n8n in a Delhi data centre keeps the workflow engine and its stored credentials on infrastructure you choose.
  • You need private access. A VPS can reach internal databases, a private network or a self-hosted app such as an Odoo server without exposing them to the internet.
  • You want predictable INR billing with a GST invoice rather than a dollar-denominated subscription.

It is a poor fit if nobody can look after a Linux server. You become responsible for updates, backups and uptime. Also read n8n's own licence: it is distributed under a "fair-code" licence (the Sustainable Use License), which allows internal business use but restricts reselling n8n as a service. Check the current terms on the n8n documentation site if you plan anything beyond running your own automations.

Size the VPS for n8n

n8n is a Node.js application. Idle, it uses a few hundred MB of RAM. Memory use rises with the size of the data passing through a workflow, for example a Code node processing a large spreadsheet or a workflow that downloads big files. As a starting point (RECOMMENDATION, not a benchmark; test with your own workflows):

WorkloadStarting planNotes
Personal or a few light workflows (webhooks, notifications, scheduled syncs)1 to 2 vCPU, 2 GB RAMAdd swap as a safety net
Business automations, PostgreSQL on the same server2 vCPU, 4 GB RAM, NVMe diskPrune old execution data
Heavy data processing, many parallel runs4 vCPU, 8 GB RAM or moreLook at n8n queue mode with workers

Disk fills mainly with execution history and binary data, not with the workflows themselves. NVMe storage helps PostgreSQL, and a plan that lets you resize later removes the guesswork. For plan specifications and current prices, use the live Linux cloud VPS plan page.

Step 1: Install Docker and Docker Compose

Install Docker from Docker's official apt repository (instructions at docs.docker.com), which includes the Compose plugin. Then confirm both work:

sudo systemctl enable --now docker
docker --version
docker compose version

Docker needs a proper virtualised server. It works well on a KVM-based VPS but can be restricted on container-based plans, so see our KVM VPS guide if you are unsure what your server runs on.

One security point: ports published by Docker bypass ufw rules in many setups, because Docker edits iptables itself. That is why the Compose file below binds n8n to 127.0.0.1 only.

Step 2: Create the Docker Compose stack with PostgreSQL

n8n uses SQLite by default, which is fine for testing. For anything you depend on, use PostgreSQL. Create a directory and two files:

mkdir -p ~/n8n && cd ~/n8n
openssl rand -hex 24   # use once for DB password
openssl rand -hex 32   # use once for the encryption key

Create .env (and set chmod 600 .env):

POSTGRES_USER=n8n
POSTGRES_PASSWORD=<first random value>
POSTGRES_DB=n8n
N8N_ENCRYPTION_KEY=<second random value>
N8N_HOST=automation.example.in
GENERIC_TIMEZONE=Asia/Kolkata

Create docker-compose.yml:

services:
  postgres:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 10s
      retries: 10

  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB}
      DB_POSTGRESDB_USER: ${POSTGRES_USER}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      N8N_HOST: ${N8N_HOST}
      N8N_PROTOCOL: https
      N8N_PROXY_HOPS: 1
      WEBHOOK_URL: https://${N8N_HOST}/
      GENERIC_TIMEZONE: ${GENERIC_TIMEZONE}
      TZ: ${GENERIC_TIMEZONE}
      EXECUTIONS_DATA_PRUNE: "true"
      EXECUTIONS_DATA_MAX_AGE: 336
    volumes:
      - n8ndata:/home/node/.n8n

volumes:
  pgdata:
  n8ndata:

Notes on the important lines:

  • N8N_ENCRYPTION_KEY encrypts the credentials (API keys, OAuth tokens) stored in the database. Set it yourself and keep a copy in a password manager. If you lose it, you cannot decrypt saved credentials after a restore.
  • WEBHOOK_URL must be the public HTTPS address, otherwise webhook nodes display wrong URLs behind the proxy.
  • GENERIC_TIMEZONE controls when Schedule nodes fire. Without it you may get UTC schedules, which is a common surprise for Indian teams expecting 9 AM IST.
  • EXECUTIONS_DATA_PRUNE and EXECUTIONS_DATA_MAX_AGE delete old execution records (the age is in hours, so 336 is 14 days). This keeps the database from growing without limit.
  • Pinning a specific version tag instead of latest is safer for production, because it lets you choose when to upgrade. Check the current tags and release notes on n8n's documentation before upgrading.

Start it with docker compose up -d and check docker compose logs -f n8n until the editor is reported as ready. Environment variable names change between n8n versions, so confirm them in the official environment variables reference for the version you run.

Step 3: Add Nginx and HTTPS

Point a DNS A record for your hostname (for example automation.example.in) to the server IP, then install Nginx and a Let's Encrypt certificate using the steps in our Ubuntu cloud server guide. Use this server block:

server {
    listen 443 ssl http2;
    server_name automation.example.in;
    # ssl_certificate lines added by Certbot

    client_max_body_size 50m;

    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_read_timeout 300s;
    }
}

The Upgrade and Connection headers matter: the n8n editor uses WebSocket (or server-sent events) for live execution updates, and without them the canvas can look stuck while a workflow runs. Open https://automation.example.in, and n8n asks you to create the owner account on first visit. Do that immediately, because until then anyone who finds the URL could claim it.

Step 4: Secure the server and the editor

  1. Allow only ports 22 (ideally restricted to your IP), 80 and 443. Port 5678 should never be public.
  2. Use a strong owner password and turn on two-factor authentication in n8n if your version offers it.
  3. Keep SSH key-only and enable unattended-upgrades for OS patches.
  4. Webhook URLs are public by design. Add authentication to webhook nodes (header auth or a secret token) and validate payload signatures where the sending service supports them.
  5. Give each integration its own API key with the least permissions it needs, so one leaked credential does not expose everything.
  6. Be careful with the Code node and community nodes: they run code on your server. Install only nodes you trust.

The monthly server management checklist turns these into recurring tasks.

Step 5: Back up what actually matters

You need three things to rebuild n8n: the PostgreSQL database (workflows, credentials, execution history), the N8N_ENCRYPTION_KEY, and your .env and Compose files. A simple nightly dump:

#!/bin/bash
set -euo pipefail
cd ~/n8n
DEST=/backup/n8n/$(date +%F)
mkdir -p "$DEST"
docker compose exec -T postgres pg_dump -U n8n -Fc n8n > "$DEST/n8n.dump"
cp .env docker-compose.yml "$DEST/"
chmod -R go-rwx "$DEST"
find /backup/n8n -maxdepth 1 -type d -mtime +14 -exec rm -rf {} +

Copy that folder off the server with rclone or rsync, because a backup on the same disk is not a backup. The backup contains your encryption key in .env, so protect the destination as carefully as the server. Our cloud server backup guide explains snapshots, offsite copies and how to run a restore test. Also export important workflows as JSON into Git so you can review changes.

Updating n8n safely

  • Read the release notes for breaking changes before changing the version tag.
  • Take a database dump or a VPS snapshot first.
  • Run docker compose pull && docker compose up -d, then open a few critical workflows and run a test execution.
  • Watch docker compose logs after the upgrade for migration errors.
  • If something breaks, restore the dump and go back to the previous image tag.

Also watch disk usage (docker system df, df -h) and remove unused images now and then with docker image prune.

India-specific points

  • Personal data and DPDP. If workflows process customer or employee personal data, India's Digital Personal Data Protection Act, 2023 applies to how you collect, protect and delete it. Hosting in India does not make you compliant by itself, but it simplifies knowing where the data sits. Execution logs may contain that data, so prune them. See MeitY for the official text, and our article on moving hosting back to India.
  • Latency. Many Indian APIs (payment gateways, GST and logistics services, WhatsApp Business providers) respond faster from a server in India. Measure from the VPS with curl -w before assuming.
  • Time zones. Set Asia/Kolkata as shown above so schedules, date formatting and daily reports match your office day.
  • Billing. INR billing with a GST invoice avoids card foreign-exchange charges and makes the expense easier to book.

How AvertHost can help

AvertHost runs managed Linux and Windows cloud VPS from a Tier-IV data centre in Delhi, with a 99.9% uptime SLA, INR billing with GST invoices and 24/7 support. A Linux cloud VPS running Ubuntu is the base for this setup. We provide the server and platform. Installing, configuring and upgrading n8n and its workflows remains your responsibility, unless you agree otherwise with the support team in writing. Check the plan page for current specifications and prices before you size the server.

FAQ

How much RAM does n8n need on a VPS?

For light workflows, 2 GB of RAM is a workable minimum. With PostgreSQL on the same server and business workloads, start with 4 GB. Memory use depends mostly on how much data a single workflow holds at once, so test with realistic data.

Is self-hosted n8n free?

You can run it on your own server without a subscription for internal use, under n8n's fair-code licence. You still pay for the server, your time for maintenance, and any paid n8n features you choose to enable. Read the current licence terms on n8n's site.

Do I need a domain and HTTPS for n8n?

Yes, in practice. Many services only deliver webhooks to HTTPS URLs, OAuth integrations need a stable callback address, and the editor handles credentials. Use a hostname with a free Let's Encrypt certificate.

Can I run n8n without Docker?

Yes, with npm and a process manager such as systemd or PM2. Docker is easier to upgrade and roll back, which is why most guides use it.

Where should I keep backups of n8n?

Keep the database dump and the encryption key somewhere other than the n8n server, for example object storage or another machine, and test a restore on a spare server at least once.