Your VPS on our global networkGlobal network: France, Germany, Lithuania, Turkey, Hong Kong, Singapore, United States, Brazil20% off your VPS at checkout with code MINUTE20, until December 28 See plans

TutorialsVPS-Minute

n8n with Docker Compose: Install, Update and Back Up

Short answer

Two containers are enough: n8n, and Caddy in front of it to get the HTTPS certificate on its own. On a 1 vCPU, 2 GB VPS running Ubuntu 24.04, the setup below was online in about two minutes, n8n used 486 MB of RAM at idle, and moving from n8n 3.3.0 to 3.4.3 took 19 seconds of downtime with every workflow still there.

What you need

  • A Linux VPS with 2 GB of RAM and Ubuntu 24.04. The n8n image alone takes 1.92 GB of disk.
  • Root access, or a user with sudo.
  • A domain name with an A record pointing to the server's IP, for example n8n.example.com. No domain yet? 203-0-113-10.sslip.io (your IP with dashes) points to 203.0.113.10 and is enough to get a real certificate for a test.
  • Ports 80 and 443 reachable from the internet: Let's Encrypt checks the domain through them.

1. Install Docker and Docker Compose

Ubuntu 24.04 ships both in its own repositories. On our test server, the install took 15 seconds.

sudo apt update
sudo apt install -y docker.io docker-compose-v2
docker --version
docker compose version
Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
Docker Compose version 2.40.3+ds1-0ubuntu1~24.04.1

If you would rather follow Docker's own repository and its release pace, the steps are on docs.docker.com. The commands below are the same with either.

2. Write the Compose file and the Caddyfile

Create a folder for the project. Compose names the volumes after it, so n8n gives you a volume called n8n_n8n_data, used again in the backup step.

mkdir ~/n8n && cd ~/n8n
compose.yaml
services:
  n8n:
    image: n8nio/n8n:3.4.3
    restart: unless-stopped
    environment:
      - N8N_HOST=n8n.example.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_WEBHOOK_URL=https://n8n.example.com/
      - N8N_PROXY_HOPS=1
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - GENERIC_TIMEZONE=Europe/Paris
      - TZ=Europe/Paris
    volumes:
      - n8n_data:/home/node/.n8n

  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config

volumes:
  n8n_data:
  caddy_data:
  caddy_config:
Caddyfile
n8n.example.com {
	reverse_proxy n8n:5678
}

Put your own domain in both files, and your time zone in place of Europe/Paris:

sed -i 's/n8n.example.com/n8n.yourdomain.com/g' compose.yaml Caddyfile

A few choices worth knowing:

  • n8n has no ports: line. Only Caddy can reach it, over the private network Compose creates, so port 5678 is never open to the internet.
  • N8N_PROXY_HOPS=1 tells n8n that one proxy sits in front of it, so it reads the visitor's real IP from Caddy.
  • N8N_WEBHOOK_URL gives your webhook nodes the public HTTPS address. Without it, n8n builds their address from the settings above and adds port 5678.
  • The version is pinned (3.4.3). An update happens when you decide, not on the next restart.

3. Start n8n

docker compose up -d
docker compose logs caddy | grep -o "certificate obtained successfully"
docker compose logs n8n --no-log-prefix | grep -A1 "Editor is now"
certificate obtained successfully
Editor is now accessible via:
https://n8n.example.com

The first start downloads the images (75 seconds on our server for the 1.92 GB of n8n), then n8n answers in about 20 seconds and Caddy gets its certificate a few seconds later. Open the address straight away and create the owner account: until that is done, whoever opens the page first can claim the instance, and every certificate is published in public logs, so a fresh domain gets visited quickly.

4. Update n8n without losing your workflows

Workflows, credentials, execution history and the encryption key all live in the n8n_data volume, not in the container. An update replaces the container and keeps the volume. Run the backup from step 5 first, then change the tag and restart. Here is the update we tested, from 3.3.0 to 3.4.3:

sed -i 's#n8nio/n8n:3.3.0#n8nio/n8n:3.4.3#' compose.yaml
docker compose pull n8n
docker compose up -d
docker compose exec n8n n8n --version
docker compose exec n8n n8n list:workflow
3.4.3
NLnZabt5Q0JoKqkF|Guide test workflow

The download took 76 seconds while the old version kept running. The restart itself took 19 seconds. To see which versions exist, the n8nio/n8n page on Docker Hub lists them: on 3 December 2026, latest and stable pointed to 3.4.3, and next to 3.5.2. Read the release notes before changing the first number of the version.

5. Back up and restore

The script stops n8n for a few seconds so the SQLite database is copied in a clean state, archives the volume, starts n8n again and keeps 14 days of archives.

backup.sh
#!/bin/sh
# Daily n8n backup: stops n8n for a few seconds, archives the data volume, keeps 14 days.
cd "$(dirname "$0")"
mkdir -p backups
docker compose stop n8n
docker run --rm -v n8n_n8n_data:/data:ro -v "$PWD/backups":/backup alpine \
  tar czf "/backup/n8n-data-$(date +%F).tar.gz" -C /data .
docker compose start n8n
find backups -name 'n8n-data-*.tar.gz' -mtime +14 -delete
chmod +x backup.sh
./backup.sh
ls -lh backups/
total 516K
-rw-r--r-- 1 root root 514K Dec  3 11:14 n8n-data-2026-12-03.tar.gz

The whole run took 4 seconds. The archive holds database.sqlite and the config file, which contains the key that decrypts your credentials: keep it as private as a password. To run it every night at 03:30, add this line with crontab -e:

30 3 * * * $HOME/n8n/backup.sh >> $HOME/n8n/backups/backup.log 2>&1

To restore, we deleted the volume and rebuilt it from the archive. n8n was back 18 seconds later, with the same owner account and the same workflow:

docker compose down
docker volume rm n8n_n8n_data
docker volume create n8n_n8n_data
docker run --rm -v n8n_n8n_data:/data -v "$PWD/backups":/backup alpine \
  sh -c "cd /data && tar xzf /backup/n8n-data-2026-12-03.tar.gz"
docker compose up -d

An archive kept on the same server does not survive the loss of the server: copy it elsewhere, or add the Daily backup option to your VPS (one copy every night, kept for 7 days). For workflows you want to track in Git, the CLI exports them as JSON:

docker compose exec n8n n8n export:workflow --all --pretty --output=/home/node/.n8n/workflows.json
docker compose cp n8n:/home/node/.n8n/workflows.json ./backups/

What we ran into

WEBHOOK_URL is the old name. Older guides still set it, and so did our first run: n8n listed it among the deprecations at startup. Since n8n 2.35, the variable is N8N_WEBHOOK_URL (environment variables). With N8N_WEBHOOK_URL, one notice is left.

The task runner notices. Every start of n8n 3.4.3 prints these two messages:

Failed to start Python task runner in internal mode. because Python 3 is missing from this system. Launching a Python runner in internal mode is intended only for debugging and is not recommended for production. Users are encouraged to deploy in external mode. See: https://docs.n8n.io/hosting/configuration/task-runners/#setting-up-external-mode
There is a deprecation related to your n8n setup. Please take the recommended actions to update your configuration:
 - N8N_RUNNERS_MODE -> Internal task runner mode is deprecated and will be removed in a future version. For isolation and scaling, run the task runner launcher as a separate process, set this variable to `external` and share `N8N_RUNNERS_AUTH_TOKEN` with the launcher. See https://docs.n8n.io/deploy/host-n8n/configure-n8n/set-up-task-runners

Workflows run, and JavaScript in Code nodes runs inside the n8n container. Python in Code nodes does not: it needs the external runner that n8n describes in its task runners documentation, which n8n also plans to make the only mode.

The firewall does not see Docker's ports. Our test server had ufw active with only port 22 allowed, and Let's Encrypt still reached Caddy on ports 80 and 443. Docker writes its own firewall rules, ahead of ufw's. That is why n8n has no ports: line here: if you need port 5678 on the server itself, publish it as "127.0.0.1:5678:5678", never as "5678:5678".

Why Caddy and not Traefik. The Compose example in the n8n documentation uses Traefik, which needs access to the Docker socket. Caddy needs a three-line file, no access to Docker, and renews its certificates by itself.

n8n in one click on VPS-Minute

Prefer not to do it by hand? On our n8n VPS, pick n8n at the Configuration step of your order: it installs on the first boot, with HTTPS, and is ready about five minutes later. The 2 GB plan used in this guide costs €3.32 a month excluding VAT, in 9 locations, and Docker alone is also offered in one click on the Docker VPS.

Related questions

On our test server, n8n used 486 MB at idle and Caddy 13 MB. A 2 GB VPS leaves room for everyday workflows; workflows that handle large files or many executions at once need more.

In the n8n_data volume, mounted at /home/node/.n8n: the database.sqlite database, plus a config file with the encryption key of your credentials. Removing the container does not touch it; removing the volume does.

Back up, change the image tag in compose.yaml, then run docker compose pull n8n and docker compose up -d. In our test, n8n was down for 19 seconds and every workflow was still there afterwards.

A pinned version is safer: with latest, the next docker compose pull can bring a major version you have not read about. On 3 December 2026, latest and stable were 3.4.3 on Docker Hub, and next was 3.5.2.

Your workflows come back, but n8n can no longer decrypt the saved credentials, and every connection has to be entered again. The archive made by backup.sh includes the key, which is one more reason to keep it private.

SQLite is n8n's default and what this guide uses: one instance, no extra container, and a backup that fits in one archive. n8n also supports PostgreSQL; it adds a container and a database dump to the backup.

For a test, yes: 203-0-113-10.sslip.io (your IP with dashes) resolves to your server, and Caddy gets a real certificate for it. For daily use, take your own domain, so the address does not change if the server does.

No. In our test, ufw allowed only port 22 and ports 80 and 443 published by Caddy were still reachable. Only publish what must be public, and bind anything else to 127.0.0.1.

Linux VPS at VPS-Minute

Monthly billing, no setup fee, delivered in 60 seconds. Pay by card, PayPal, Paysafecard or crypto.

Prices incl. VAT

Server location

Linux S

2 GB RAM

€3.98/mo€3.98-20%€3.19/mo

€3.32/mo€39.84 paid yearly€3.32-20%€2.66/mo€31.87 paid yearly

  • 1 vCPU
  • 30 GB SSD
  • Unlimited bandwidth
  • Dedicated IPv4
  • IPv6 /64 included
  • 24 Tbps DDoS protection
  • KVM
  • Delivered in one minute
Order
Linux M

4 GB RAM

€5.99/mo€5.99-20%€4.79/mo

€4.99/mo€59.88 paid yearly€4.99-20%€3.99/mo€47.90 paid yearly

  • 2 vCPU
  • 50 GB SSD
  • Unlimited bandwidth
  • Dedicated IPv4
  • IPv6 /64 included
  • 24 Tbps DDoS protection
  • KVM
  • Delivered in one minute
Order
Linux LRecommended

8 GB RAM

€9.98/mo€9.98-20%€7.99/mo

€8.32/mo€99.84 paid yearly€8.32-20%€6.66/mo€79.87 paid yearly

  • 4 vCPU
  • 80 GB SSD
  • Unlimited bandwidth
  • Dedicated IPv4
  • IPv6 /64 included
  • 24 Tbps DDoS protection
  • KVM
  • Delivered in one minute
Order
Linux XL

16 GB RAM

€17.99/mo€17.99-20%€14.39/mo

€14.99/mo€179.88 paid yearly€14.99-20%€11.99/mo€143.90 paid yearly

  • 6 vCPU
  • 160 GB SSD
  • Unlimited bandwidth
  • Dedicated IPv4
  • IPv6 /64 included
  • 24 Tbps DDoS protection
  • KVM
  • Delivered in one minute
Order
Linux XL24

24 GB RAM

€24.98/mo€24.98-20%€19.99/mo

€20.82/mo€249.84 paid yearly€20.82-20%€16.66/mo€199.87 paid yearly

  • 8 vCPU
  • 200 GB SSD
  • Unlimited bandwidth
  • Dedicated IPv4
  • IPv6 /64 included
  • 24 Tbps DDoS protection
  • KVM
  • Delivered in one minute
Order
Linux XXL

32 GB RAM

€31.99/mo€31.99-20%€25.60/mo

€26.66/mo€319.92 paid yearly€26.66-20%€21.33/mo€255.94 paid yearly

  • 8 vCPU
  • 240 GB SSD
  • Unlimited bandwidth
  • Dedicated IPv4
  • IPv6 /64 included
  • 24 Tbps DDoS protection
  • KVM
  • Delivered in one minute
Order
    • Root or administrator access
    • No commitment

    Card, PayPal, Apple Pay or local payment

    • Visa
    • Mastercard
    • PayPal
    • iDEAL
    • Apple Pay
    • Bancontact
    • EPS
    • Pay by Bank
    • Paysafecard
    • Bancomat Pay

    Over 300 customer reviews

    Currently sold out

    Get an email as soon as this location is available again.

    Got it. We will email you as soon as this location is available again.

    This email address is not valid.

    Too many attempts from your connection. Try again in an hour.

    This location is available again.

    The sign-up did not go through. Try again in a few minutes.

    Your address has been deleted: you will not get anything.

    You can unsubscribe at any time.