n8n is a workflow automation tool, like Zapier or Make, that you can host yourself. You connect apps and services (Gmail, Slack, Google Sheets, Xero, webhooks, AI models and hundreds more) with a visual editor, and your automations run on your own VPS with no per-task fees.
This guide runs n8n in Docker, with Caddy in front of it to provide a free HTTPS certificate automatically. HTTPS matters here, because most services that send webhooks to n8n require it. The guide works on every operating system we offer: Ubuntu 22.04, 24.04 and 26.04, Debian 12 and 13, AlmaLinux 8, 9 and 10, and Rocky Linux 9 and 10.
Before you start
- A VPS with at least 2 GB of RAM. Add more if you plan to run large or frequent workflows.
- A domain or subdomain with an A record pointing to your VPS IP address, for example
n8n.example.co.nz. - Nothing else using ports 80 or 443 on the server.
- SSH access as root or as a user with sudo rights. If you're logged in as root, you can leave
sudooff the commands.
Step 1: Install Docker
Skip this step if Docker is already installed (docker --version shows a version).
Ubuntu 22.04, 24.04, 26.04 and Debian 12, 13
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
. /etc/os-release
sudo curl -fsSL https://download.docker.com/linux/$ID/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/$ID
Suites: ${UBUNTU_CODENAME:-$VERSION_CODENAME}
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
AlmaLinux 8, 9, 10 and Rocky Linux 9, 10 (this removes Podman, which conflicts with Docker):
sudo dnf remove -y podman runc
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
All systems: start Docker and check it works.
sudo systemctl enable --now docker
sudo docker run --rm hello-world
Step 2: Open the firewall
Ubuntu/Debian with UFW enabled:
sudo ufw allow 80/tcp
sudo ufw allow 443
AlmaLinux/Rocky with firewalld:
sudo firewall-cmd --permanent --add-service=http --add-service=https --add-port=443/udp
sudo firewall-cmd --reload
Step 3: Create the configuration files
sudo mkdir -p /opt/n8n
cd /opt/n8n
sudo nano .env
Paste in the following, replacing the domain with your own. Change the time zone if you're not in New Zealand.
DOMAIN=n8n.example.co.nz
GENERIC_TIMEZONE=Pacific/Auckland
Press Ctrl+O and Enter to save, then Ctrl+X to exit. Next, create the Docker Compose file:
sudo nano compose.yaml
Paste in the following. You don't need to change anything in this file.
services:
n8n:
image: n8nio/n8n
container_name: n8n
restart: unless-stopped
environment:
- N8N_HOST=${DOMAIN}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://${DOMAIN}/
- N8N_PROXY_HOPS=1
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- TZ=${GENERIC_TIMEZONE}
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_RUNNERS_ENABLED=true
- NODE_ENV=production
volumes:
- n8n_data:/home/node/.n8n
caddy:
image: caddy:2
container_name: caddy
restart: unless-stopped
environment:
- DOMAIN=${DOMAIN}
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes:
n8n_data:
caddy_data:
caddy_config:
Save and exit. Finally, create the Caddy configuration:
sudo nano Caddyfile
Paste in the following exactly as shown. Caddy reads your domain from the .env file.
{$DOMAIN} {
reverse_proxy n8n:5678
}
Save and exit.
Step 4: Start n8n
sudo docker compose up -d
Caddy gets an SSL certificate for your domain automatically. This usually takes under a minute.
Step 5: Create your owner account
Open https://n8n.example.co.nz straight away and set up the owner account with your email address and a strong password. Until you do, anyone who finds the page could claim it. Once you're in, click Create workflow to build your first automation, or browse the ready-made templates.
Back up your data
Everything n8n stores, including your workflows, saved credentials and the encryption key that protects them, is kept in the n8n_data Docker volume. If you lose that volume, your saved credentials can't be recovered. Back it up regularly, for example:
cd /opt/n8n
sudo docker compose stop n8n
sudo docker run --rm -v n8n_n8n_data:/data -v /opt/n8n:/backup alpine tar czf /backup/n8n-backup.tar.gz -C /data .
sudo docker compose start n8n
Copy the backup file off the server, for example to your computer or cloud storage.
n8n uses a built-in SQLite database, which suits most small and medium setups. For heavy use or a team, n8n recommends PostgreSQL. See n8n's example setup with PostgreSQL.
Keeping it up to date
Check the n8n release notes for breaking changes, take a backup, then run:
cd /opt/n8n
sudo docker compose pull
sudo docker compose up -d
Troubleshooting
- The site won't load over HTTPS: check the Caddy logs with
sudo docker logs caddy. The usual cause is DNS that doesn't point to this VPS yet, or ports 80 and 443 being blocked. - Webhook URLs show
localhostor the wrong address: checkDOMAINin/opt/n8n/.env, then runsudo docker compose up -dagain. - n8n stops or restarts during big workflows: the server may be out of memory. Check with
sudo docker logs n8n, and consider upgrading your VPS.
Need help?
Our Cloud VPS plans are self-managed, so you're responsible for installing, securing and maintaining the software on your server. If something on our side isn't working, such as the network, or your VPS won't boot, open a support ticket. New to your VPS? Start with our Cloud VPS Getting Started Guide.







