Skip to content
COL0

Deploy n8n on a VPS step by step with Docker

n8n is a tool that automates tasks by connecting apps. Running it on your own VPS gives you control over your data and over where it runs.

Written by Victor Barrera

The concepts you need

  • VPS: your own virtual server running Linux, where n8n runs 24/7.
  • Docker Compose: a file (compose.yaml) that starts n8n and the HTTPS proxy together.
  • Volume: the folder where n8n stores workflows, credentials and its encryption key. It is the most important thing to back up.
  • Webhook: the public address other apps call to trigger a workflow.

The steps, in short

Commands follow the official documentation (October 2026), except ufw (Ubuntu) and the backup tar (Docker’s volume pattern), which are not from the n8n documentation.

  1. Create a VPS with Ubuntu LTS and connect over SSH with a non-root user that can use sudo. First time? Follow Linux VPS from scratch.
  2. Install Docker and the Compose plugin using the official Docker documentation. If docker compose version shows a version, it worked.
  3. Point a subdomain at the server: create an A DNS record (for example n8n.yourdomain.com) with your VPS IP. If DNS is new to you, read Domain, DNS and HTTPS.
  4. Create the working folder and local-files (the compose mounts it at /files):
mkdir n8n-compose
cd n8n-compose
mkdir local-files
nano .env

In nano, paste this with your details, save (Ctrl+O, Enter) and exit (Ctrl+X):

DOMAIN_NAME=yourdomain.com
SUBDOMAIN=n8n
GENERIC_TIMEZONE=America/Bogota
SSL_EMAIL=you@example.com
  1. Copy the official compose.yaml from the n8n Docker Compose guide into that folder, unchanged. It includes n8n, Traefik (the proxy that gets the HTTPS certificate) and the n8n_data volume.
  2. Open ports 22 (SSH), 80 (redirects to HTTPS) and 443 (n8n). Allow 22 before enabling ufw, or you lock yourself out:
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

ufw enable asks for confirmation: answer y; it should say the firewall is active. Docker publishes its ports bypassing ufw; so anything that must not be public goes with 127.0.0.1: in front. If your provider has a firewall, open the same ports there. 7. Start everything:

sudo docker compose up -d

With sudo docker compose ps you should see n8n and Traefik running.

  1. Open https://n8n.yourdomain.com, create your owner account and test a workflow with a webhook.
  2. Back up before updating. With SQLite (the default database), n8n must be stopped while you copy:
sudo docker compose stop
sudo docker volume ls
sudo docker run --rm -v n8n-compose_n8n_data:/data -v "$PWD":/backup ubuntu tar czf /backup/n8n_data.tar.gz -C /data .
ls -lh n8n_data.tar.gz

Compose puts the folder name before the volume name (n8n-compose_n8n_data); confirm it in volume ls or the backup will be empty. n8n_data.tar.gz must appear with a size above zero. Copy it off the server and keep it somewhere private: it includes your credentials and the encryption key. If you are not updating now, start n8n again with sudo docker compose up -d. 10. Update. Read the release notes and the update guide. Then:

sudo docker compose pull
sudo docker compose down
sudo docker compose up -d

sudo docker compose ps must show n8n and Traefik running; if it fails, restore using the backup guide.

Common mistakes

  • Not mounting the volume and losing workflows and credentials on update.
  • Updating without a backup or the release notes, or copying the volume while n8n is running.
  • Keeping the backup only on the server, or without the encryption key: it is in the config file inside .n8n (in the volume), unless you set N8N_ENCRYPTION_KEY. Without it you cannot recover credentials.
  • In compose.yaml, changing 127.0.0.1:5678:5678 to 5678:5678: n8n is exposed over HTTP, bypassing ufw.
  • Forgetting the timezone: scheduled workflows run at an unexpected time.

How we help

We leave n8n running on your server with a domain, HTTPS, volume backups and a clear update flow, and we show you how to operate it yourself.

Frequently asked questions

How big a server do I need for n8n?

The n8n hosting page does not list CPU or RAM numbers. Start with a small VPS and move up a plan if it feels slow with many workflows at once or large files. The software prerequisites are at https://docs.n8n.io/deploy/host-n8n/.

Why do my webhooks not work after installing n8n?

Almost always the webhook URL. n8n needs to know its public address: from n8n 2.30.0 it uses the variable N8N_WEBHOOK_URL; before, WEBHOOK_URL. Your domain must also point to the server with HTTPS. The official compose.yaml already sets it.

Do I lose my workflows if I update or restart the container?

No, as long as you mount a volume at /home/node/.n8n. Your workflows, credentials and encryption key live there. Without a volume, everything is lost when the container is replaced.

Want us to get n8n running on your VPS?

Tell us what you want to automate and where your server is. We set it up with a domain, HTTPS and volume backups, and show you how to run it. If it helps, we talk it through in the free 30-minute session.

Tell us about your n8n setup