n8n VPS guide
Self-host n8n on a VPS.
Step by step.
n8n is a workflow automation tool: you connect apps, AI models and scripts by dragging boxes, and your workflows run on their own. This guide shows how to install it on your own HostingBaba Linux VPS with Docker and HTTPS, so it runs around the clock.
What you need
A Linux VPS with Ubuntu 24.04 LTS (choose it on the order form), a domain or subdomain you control, such as n8n.yourdomain.com, and SSH access from your own computer. How much memory n8n needs depends on how many workflows run at the same time and how much data they handle. Our smallest VPS plan has 4 vCPU and 8 GB of memory; start there and move to a bigger plan if your server runs short. Running AI models on the server itself needs much more memory and processing power.
n8n is made by n8n GmbH. Its free self-hosted Community Edition may be used for your own internal business or personal use under the n8n Sustainable Use License; read it before you use n8n for clients. HostingBaba is not affiliated with n8n.
Step 1: point your domain at the server
When your server is ready, copy its IPv4 address from your dashboard. At your domain provider, add an A record for your subdomain (for example n8n) with that address. It usually starts working within minutes; check that the name shows your server's address with:
ping n8n.yourdomain.com
Step 2: install Docker
Log in to the server over SSH as root with the details from your dashboard. Update it, then install Docker from Docker's own package repository, as Docker's guide for Ubuntu describes:
apt update && apt -y upgrade
apt install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" > /etc/apt/sources.list.d/docker.list
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 3: create the n8n setup
Make a folder and a file called compose.yaml. Replace n8n.yourdomain.com with your own subdomain (three times) and pick your time zone. n8n listens only on the server itself (127.0.0.1); Caddy gets a free HTTPS certificate and is the only part reachable from the internet.
mkdir -p /opt/n8n && cd /opt/n8n
nano compose.yaml
services:
n8n:
image: docker.n8n.io/n8nio/n8n
restart: unless-stopped
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_HOST=n8n.yourdomain.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://n8n.yourdomain.com/
- N8N_PROXY_HOPS=1
- GENERIC_TIMEZONE=Europe/London
- TZ=Europe/London
volumes:
- n8n_data:/home/node/.n8n
caddy:
image: caddy:2
restart: unless-stopped
ports:
- "80:80"
- "443:443"
command: caddy reverse-proxy --from n8n.yourdomain.com --to n8n:5678
volumes:
- caddy_data:/data
volumes:
n8n_data:
caddy_data:
Step 4: claim n8n privately, then go public
The first person to open a new n8n creates its owner account, so do that before n8n is reachable from the internet. Start n8n on its own:
docker compose up -d n8n
On your own computer, open an SSH tunnel to the server (use your server's address), keep that window open, and go to http://localhost:5678 in Chrome or Firefox (Safari does not allow the n8n login here; use one of the others for this step). Create your owner account with a strong password.
ssh -L 5678:127.0.0.1:5678 root@YOUR.SERVER.IP
Then start Caddy, close the tunnel and open https://n8n.yourdomain.com. If it does not load yet, wait a minute while the certificate is issued and check the logs with docker compose logs caddy.
docker compose up -d
Step 5: firewall, updates and backups
Turn on the firewall for SSH. If you use a different SSH port, allow that one instead of OpenSSH. Note that ports published by Docker bypass this firewall: here only Caddy publishes ports 80 and 443, and n8n is bound to 127.0.0.1, so do not publish other containers' ports to the internet unless you mean to.
ufw allow OpenSSH
ufw enable
Your workflows, credentials and encryption key live in the n8n_data volume. To make a safe backup, stop n8n for a moment, archive the volume, then start it again. Copy the file off the server, for example with scp, and keep it somewhere else.
cd /opt/n8n
docker compose stop n8n
docker run --rm -v n8n_n8n_data:/data:ro -v /opt/n8n:/backup alpine tar czf /backup/n8n-backup.tgz -C /data .
docker compose start n8n
To update n8n, read its release notes, make a backup as above, then run:
cd /opt/n8n
docker compose pull && docker compose up -d
We do not back up your server by default, so keep your own copies.
What is not allowed
Your server, and everything n8n does from it, must follow our Acceptable Use Policy: no spam of any kind, including unsolicited messages and posting links or comments on other people's sites without permission, no getting around platform bans or fraud and detection systems, and no scanning systems you are not allowed to test. Serious abuse such as phishing, malware, attacks or fraud stops the server at once; for other complaints you reply within 12 hours and fix it within 24.