Self-hosting n8n in short
To self-host n8n, run the official Docker image on a Linux VPS, put a reverse proxy such as Caddy in front of it for HTTPS, and keep the /home/node/.n8n folder in a persistent volume. Set your public webhook URL, the Asia/Kolkata timezone and a fixed encryption key before the first start. The free Community edition then runs with almost the full feature set.
Before you start, read the licence. Self-hosted n8n uses the Sustainable Use License, which n8n describes as fair-code. It is source-available, not an OSI-approved open source licence. You may use it to run your own business, for personal projects, and to build and maintain automations for clients on your instance. You may not host n8n as a service where your customers build or edit their own workflows, or white-label it. n8n's licence FAQ, linked under Sources, gives more examples.
What you need: VPS size, disk and database
n8n's production requirements recommend a 64-bit Linux host and Docker Engine with the Compose v2 plugin. Docker needs a real kernel, so use a KVM VPS rather than a container-based one.
RAM and vCPU
n8n does not publish one minimum for a plain instance, because memory use depends on your workflows. Its memory guide lists what pushes usage up: large JSON payloads, binary files, many nodes, the Code node, manual test runs (n8n keeps a copy of the data for the editor), and several workflows running at once. The firmest figure in the docs is in n8n's Docker Compose install guide, which asks for at least 4 GB of RAM and 2 vCPUs for the stack that includes the n8n Assistant code sandbox. n8n's Hetzner guide says a small plan is enough for most usage levels without Assistant.
A practical approach: start on 2 vCPU and 4 GB RAM, watch real usage with docker stats for a week, and resize if memory stays high. Our guide on how much RAM a VPS needs explains how to read those numbers.
Disk
Workflows themselves are small. Execution history and binary data are what grow. By default n8n prunes execution data older than 336 hours (14 days) and keeps at most 10,000 executions, controlled by EXECUTIONS_DATA_MAX_AGE and EXECUTIONS_DATA_PRUNE_MAX_COUNT. Lower them if you process files.
SQLite or Postgres
| SQLite (default) | PostgreSQL | |
|---|---|---|
| Setup | Nothing to install, one file in .n8n | Separate service, user and backups |
| n8n's advice | Fine for testing and small setups | Recommended for production |
| Queue mode | Not supported | Required |
| Supported versions | Bundled | 16, 17 and 18 (n8n docs, as of July 2026; the range shifts each year) |
| Backup | Copy the .n8n volume with n8n stopped | pg_dump plus the .n8n volume |
A single person or small team automating their own work can start on SQLite. If several people build workflows, or workflows run around the clock, start on Postgres, because moving later is a migration, not a switch.
Prepare the VPS and point a subdomain
- Do the usual first-boot work: updates, a sudo user, SSH keys. Our Ubuntu VPS initial setup guide covers it for Ubuntu 24.04.
- Install Docker Engine and the Compose plugin from Docker's own apt repository, as described in how to install Docker on Ubuntu. Check with
docker compose version. - Create an A record such as
n8n.example.compointing to the server's IP. See pointing a domain to a VPS if you have not done this before. - Open only SSH, HTTP and HTTPS in the firewall:
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Port 80 must be reachable so the proxy can get a Let's Encrypt certificate. Port 5678 stays closed. Note that Docker's documentation says Docker and ufw are not compatible: a port you publish with Docker skips ufw rules. The setup below therefore does not publish 5678 at all. Only the proxy talks to n8n, over Docker's internal network.
Install n8n with Docker Compose and Caddy
n8n's own examples use Traefik. Caddy is shorter to configure and also gets and renews Let's Encrypt certificates on its own. Create a project folder and a config folder:
mkdir -p ~/n8n/conf && cd ~/n8n
Create .env with your domain, then add a random encryption key and lock the file down:
echo "N8N_DOMAIN=n8n.example.com" > .env
echo "N8N_ENCRYPTION_KEY=$(openssl rand -hex 32)" >> .env
chmod 600 .env
Create compose.yaml:
services:
n8n:
image: n8nio/n8n:2.48.7
restart: unless-stopped
environment:
- N8N_HOST=${N8N_DOMAIN}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- N8N_WEBHOOK_URL=https://${N8N_DOMAIN}/
- N8N_PROXY_HOPS=1
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- GENERIC_TIMEZONE=Asia/Kolkata
- TZ=Asia/Kolkata
volumes:
- n8n_data:/home/node/.n8n
caddy:
image: caddy:2
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./conf:/etc/caddy
- caddy_data:/data
- caddy_config:/config
depends_on:
- n8n
volumes:
n8n_data:
caddy_data:
caddy_config:
Create conf/Caddyfile:
n8n.example.com {
reverse_proxy n8n:5678
}
Start the stack and follow the logs:
docker compose up -d
docker compose logs -f
Open https://n8n.example.com and create the owner account straight away, because until you do, anyone who finds the URL can claim it. The Caddy image documentation recommends mounting the conf folder rather than the single Caddyfile, so edits are picked up reliably. Version 2.48.7 was n8n's stable release when this was written on 23 November 2026. Check the n8n changelog (linked under Sources) and pin the current stable version.
WEBHOOK_URL, N8N_HOST, timezone and the encryption key
Webhook URL and host
n8n builds webhook URLs from N8N_PROTOCOL, N8N_HOST and N8N_PORT. Behind a proxy that gives the wrong answer, because n8n listens on 5678 while the public sees 443. So set the public URL explicitly. From n8n 2.30.0 the variable is N8N_WEBHOOK_URL. On versions before 2.30.0, use WEBHOOK_URL instead. From 2.35.0 WEBHOOK_URL is deprecated and n8n logs a deprecation warning when it is set, so switch to N8N_WEBHOOK_URL. Set N8N_PROXY_HOPS=1 for a single proxy so n8n trusts the forwarded headers. Caddy sends X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host by default, and its reverse proxy also handles WebSocket connections, which the n8n editor uses. If you use Nginx instead, add those headers and the WebSocket upgrade headers yourself.
Timezone
GENERIC_TIMEZONE controls Schedule Trigger and other time-based nodes, and defaults to America/New_York. Without it, a workflow set for 9 a.m. runs at 9 a.m. New York time. TZ sets the container's system clock for scripts and logs. Set both to Asia/Kolkata.
Encryption key
n8n encrypts every saved credential (API keys, OAuth tokens, database passwords) with a key. If you do not set one, n8n generates a random key on first launch and stores it in the config file inside /home/node/.n8n. n8n's backup docs are clear: without that key, a restored database cannot decrypt its credentials. Setting N8N_ENCRYPTION_KEY yourself, as above, means the key also lives in .env, which you can store in a password manager. If you are adding the variable to an existing instance, copy the key from the existing config file rather than generating a new one.
Backups and updates
Full backup
The whole instance on SQLite is the n8n_data volume: database, encryption key and settings. n8n's docs say to stop n8n before copying it, so the SQLite file is consistent. Check the volume name with docker volume ls (Compose prefixes it with the folder name), then:
cd ~/n8n
docker compose stop n8n
docker run --rm -v n8n_n8n_data:/data -v "$PWD":/backup alpine \
tar czf /backup/n8n-data-$(date +%F).tar.gz -C /data .
docker compose start n8n
Copy the archive and .env off the server. On Postgres, also back up the database with pg_dump.
Exporting workflows
For moving workflows between instances, the n8n CLI exports each workflow and credential as a separate JSON file. Use different folders for each:
docker compose exec -u node n8n n8n export:workflow --backup --output=/home/node/.n8n/backups/workflows/
docker compose exec -u node n8n n8n export:credentials --backup --output=/home/node/.n8n/backups/credentials/
Credentials stay encrypted in this export, so they only import into an instance with the same key. The export does not include users, execution history or variables, so it does not replace the full backup.
Updating
n8n recommends a full backup before every update. On a VPS, a snapshot is the fastest rollback point (see how incremental snapshots work). Then change the image tag in compose.yaml and run:
docker compose pull
docker compose down
docker compose up -d
Read the release notes before jumping several versions. n8n's docs also say that from n8n 3.0, self-hosting will require a Docker-based install, so npm installs are worth moving to Docker now.
Scaling: queue mode with Redis and workers
By default one n8n process receives webhooks, runs the editor and executes every workflow. Queue mode splits this: the main instance puts executions into Redis, and separate worker processes pick them up. Its requirements, from n8n's docs:
- PostgreSQL. Queue mode over SQLite is not supported.
- Redis, set with
QUEUE_BULL_REDIS_HOSTandQUEUE_BULL_REDIS_PORT. EXECUTIONS_MODE=queueon the main instance and every worker.- The same
N8N_ENCRYPTION_KEYon every worker, or workers cannot read credentials. - Workers started with the
workercommand. Each runs 10 jobs at once by default, changed with--concurrency.
Consider it when long or heavy workflows delay webhook responses, or when one VPS is no longer enough and you want workers on a second server. Queued jobs live in Redis, so if Redis loses its data those executions do not complete. Turn on Redis persistence (AOF) and alert on executions that never finish. For one team's automations, a single instance with Postgres is usually enough.
Common errors and fixes
- Webhook URLs show
http://localhost:5678.N8N_WEBHOOK_URL(orWEBHOOK_URLbefore 2.30.0) is missing. Add it, then rundocker compose up -dso the container is recreated. Then unpublish and publish again any workflow whose trigger registers a webhook with an outside service, so it picks up the new URL. - 502 Bad Gateway from the proxy. The proxy cannot reach n8n. Check
docker compose psanddocker compose logs n8n: n8n may still be starting, restarting after running out of memory, or the Caddyfile may name the wrong service or port. Our 502 Bad Gateway guide covers the general checks. - No certificate, or the browser warns about HTTPS. DNS does not point to the server yet, or port 80 or 443 is blocked. Fix DNS, then restart Caddy.
- Credentials fail after a redeploy. Either the volume was deleted (
docker compose down -vremoves named volumes) or n8n started with a different encryption key. Restore the volume backup and the original key. - Schedules run at odd hours.
GENERIC_TIMEZONEis not set toAsia/Kolkata. - "JavaScript heap out of memory" in the logs. Process data in smaller batches, use sub-workflows, or add RAM. n8n's memory guide explains each option.
Running n8n on Bigdomainhost
A Bigdomainhost KVM VPS runs Docker natively with full root access, on servers in Mumbai (BOM-1) or Delhi NCR (DEL-1). The entry Linux plan has 2 vCPU, 4 GB RAM, 40 GB NVMe and 5 TB of transfer, and the current price is on the VPS page. Servers are prepaid in 30-day periods, snapshots are available, and there is no free trial. Support is on WhatsApp at +91 75994 50220 at any time and by phone in IST working hours.
Written by the Bigdomainhost team with AI assistance; facts checked against the linked sources.
Sources (checked )
- n8n Docs: Production requirements
- n8n Docs: Configure webhook URLs with reverse proxy
- n8n Docs: Back up and restore
- n8n Docs: Enable queue mode
- n8n Docs: Community license FAQ (Sustainable Use License)
- Caddy: reverse_proxy directive
- n8n Docs: Install using Docker Compose
- n8n Docs: Deploy to Hetzner
- n8n Docs: Choose n8n's database
- n8n Docs: Manage execution data
- n8n Docs: Changelog
- n8n Docs: n8n 2.0 breaking changes