VPS

How to install n8n on a VPS step by step

n8n connects APIs, email, spreadsheets, databases and AI models with visual workflows. You can pay for their cloud, but self-hosting it on a VPS has two main advantages: your data and credentials stay on your server, and the price does not depend on the number of executions.

Here we install it with Docker and publish it over HTTPS, production-ready.

What you need

  • A VPS with Ubuntu 24.04 (or Debian). To start, 1-2 vCores and 2 GB of RAM are plenty; you can upgrade later without reinstalling.
  • A subdomain pointing to the VPS IP (for example n8n.yourdomain.com, DNS A record).
  • SSH access as root.

Step 1: install Docker

apt update && apt install -y docker.io
systemctl enable --now docker

Step 2: start n8n

docker volume create n8n_data
docker run -d --name n8n --restart unless-stopped \
  -p 127.0.0.1:5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_HOST=n8n.yourdomain.com \
  -e WEBHOOK_URL=https://n8n.yourdomain.com/ \
  -e GENERIC_TIMEZONE=Europe/Madrid \
  docker.n8n.io/n8nio/n8n

Note the 127.0.0.1:5678 detail: n8n only listens on the machine itself. Never expose it directly to the internet without HTTPS in front.

Step 3: HTTPS with Caddy

Caddy is the simplest reverse proxy: it obtains and renews the SSL certificate on its own.

apt install -y caddy

Edit /etc/caddy/Caddyfile so it reads:

n8n.yourdomain.com {
    reverse_proxy 127.0.0.1:5678
}

Reload and done:

systemctl reload caddy

Remember to keep ports 80 and 443 open in the server firewall (on a GINERNET VPS, from the Firewall section of the Manager).

Step 4: first login

Open https://n8n.yourdomain.com, create the admin account and start building workflows. Webhooks (the reason n8n needs an always-on server with a public IP) already work: any external service can call https://n8n.yourdomain.com/webhook/... at any time.

Updating n8n

n8n releases constantly. To update without losing anything (data lives in the n8n_data volume):

docker pull docker.n8n.io/n8nio/n8n
docker stop n8n && docker rm n8n

…then run the docker run from step 2 again.

Backups

All state (workflows, encrypted credentials, history) lives in the Docker volume. A simple backup:

docker run --rm -v n8n_data:/data -v /root/backups:/backup alpine \
  tar czf /backup/n8n-$(date +%F).tar.gz -C /data .

Schedule it in a weekly cron and keep a copy off the server.

If your workflows grow (lots of AI nodes, scraping, queues…), upgrade the VPS RAM live from the Manager: With 4 GB of RAM n8n runs more comfortably.