OrbitHost
AI

Self-Host n8n on Ubuntu VPS with Docker Compose

Run n8n on Ubuntu 24.04 using Docker Compose, persistent volumes, reverse proxy TLS, and sane resource limits for European automation workloads.

By Noah Keller · Developer Advocate9 min read
Author
Noah Keller
Developer Advocate

Noah writes practical guides for Next.js deploys, AI self-hosting (Ollama, n8n), and PaaS panels like Coolify and Dokploy. His focus is getting apps from git clone to HTTPS with the fewest moving parts.

What you will build

n8n in Docker with a named volume, published only to localhost or behind Caddy/Nginx, on Ubuntu 24.04 KVM. Optional webhook URL with HTTPS for Telegram/Slack/Stripe callbacks.

OrbitHost Docker VPS in FRA/AMS keeps automation close to EU SaaS APIs and your own Ollama box.

Prerequisites

Install Docker Engine + Compose plugin first (see our Docker Ubuntu guide). Create a directory under `/opt/n8n` owned by your deploy user.

sudo mkdir -p /opt/n8n
sudo chown $USER:$USER /opt/n8n
cd /opt/n8n

Compose file for n8n

Set a strong `N8N_ENCRYPTION_KEY` and stable hostname values. Without a fixed encryption key, restarting on a new volume state can break credential decryption.

services:
  n8n:
    image: n8nio/n8n:latest
    restart: unless-stopped
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      - N8N_HOST=n8n.example.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://n8n.example.com/
      - GENERIC_TIMEZONE=Europe/Berlin
      - N8N_ENCRYPTION_KEY=replace_with_long_random_string
    volumes:
      - n8n_data:/home/node/.n8n
volumes:
  n8n_data:

Start and first login

Bring the stack up and create the owner account on first visit via the tunnel or proxy. Enable 2FA in n8n when available for your version.

cd /opt/n8n
docker compose up -d
docker compose logs -f n8n

HTTPS reverse proxy sketch

Point DNS to the VPS and proxy to `127.0.0.1:5678`. Webhooks from the public internet require a real HTTPS URL that matches `WEBHOOK_URL`.

server {
    listen 443 ssl http2;
    server_name n8n.example.com;
    # ssl_certificate managed by certbot

    location / {
        proxy_pass http://127.0.0.1:5678;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Connecting to Ollama and other local AI

When Ollama runs on the same Docker network, call `http://ollama:11434`. On the host network, use `http://127.0.0.1:11434` only if n8n can reach it — user-namespace and bridge networking differ.

Keep secrets in n8n credentials, not in plain Function nodes committed to git.

Backups and upgrades

Back up the `n8n_data` volume regularly. Upgrade by pinning a version tag, `docker compose pull`, and recreating the container during a quiet window.

For teams that hate editing YAML, Coolify on OrbitHost can own TLS and deploys while you keep the same n8n habits.

  • Pin image tags in production
  • Document webhook URLs per env
  • Test credential restore after backup drills
  • Watch disk if execution data retention is high

FAQ

How much RAM for n8n?

2 GB works for light personal workflows. 4 GB is more comfortable once you add binaries, browsers in workflows, or many concurrent executions.

SQLite or Postgres?

SQLite is fine to start. Move to Postgres when you need concurrency, larger execution history, or multiple n8n processes.

Do I need a queue mode?

Main mode is enough for individuals. Queue mode (redis + workers) helps teams with heavy parallel executions.

Is Coolify better?

Coolify can deploy n8n for you. Raw Compose is clearer when you want exact env control and minimal platform layers.

Ready to Launch?

Create your server today.