Skip to content
Back to blog

Magichosting

Self-hosting n8n: installation with Docker, HTTPS and backups

E
Elias Bieber
Estimated reading time: 4 min

n8n on your own server: install it in one click or with Docker Compose, put it behind a reverse proxy with HTTPS and back up your workflows safely.

n8nAutomationDockerHTTPSLinux

Why self-host n8n?

n8n connects apps, APIs, webhooks, databases and AI models into automated workflows – from Discord alerts and invoice filing to AI agents. Self-hosted, n8n doesn't count executions, your data stays on your server and you pay a fixed price. In return you handle HTTPS, updates and backups yourself – which is exactly what this guide shows.

  • Resources: For your own workflows, 2 vCores and 4 GB RAM are enough; for teams and many webhooks, 4 vCores and 8 GB are a good start.
  • Operating system: Debian or Ubuntu on a KVM server.
  • Domain: A subdomain such as n8n.your-domain.com with an A record pointing to your server's IPv4.

Option 1: n8n in one click with the Autoinstaller

  1. Open your KVM server in the dashboard and switch to the Autoinstaller tab.
  2. Choose n8n. The Autoinstaller sets up Docker and starts n8n with Docker Compose in /opt/n8n.
  3. Open http://YOUR-SERVER-IP:5678 and create your owner account.

Option 2: Docker Compose by hand

With Docker installed (guide: Docker Engine on Debian 12), create this file and start it with docker compose up -d:

yaml
# /opt/n8n/docker-compose.yml
services:
  n8n:
    image: n8nio/n8n:latest
    restart: unless-stopped
    ports:
      - "127.0.0.1:5678:5678"   # local only – the reverse proxy forwards
    environment:
      N8N_HOST: n8n.your-domain.com
      N8N_PROTOCOL: https
      N8N_PORT: "5678"
      WEBHOOK_URL: https://n8n.your-domain.com/
      GENERIC_TIMEZONE: Europe/Berlin
      TZ: Europe/Berlin
    volumes:
      - ./data:/home/node/.n8n

If you use the Autoinstaller variant, add the same variables there and remove N8N_SECURE_COOKIE: "false" once HTTPS is active.

Setting up HTTPS

With Nginx Proxy Manager

Nginx Proxy Manager is also available in the Autoinstaller. In its interface (port 81), create a proxy host for your n8n subdomain, enter your server's IP and port 5678 as the target, enable Websockets Support and request a Let's Encrypt certificate in the "SSL" tab. If n8n runs with 127.0.0.1:5678, use the host's Docker bridge address as the target instead, or publish the port only within a shared Docker network.

With Nginx and Certbot

The most important lines are the websocket headers – without them the editor won't update live:

nginx
server {
    server_name n8n.your-domain.com;
    location / {
        proxy_pass http://127.0.0.1:5678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

Then get the certificate with certbot --nginx -d n8n.your-domain.com. The basics are in Nginx as a reverse proxy with Let's Encrypt.

Backups and updates

Everything important lives in the data folder (/opt/n8n/data): the database, settings and the encryption key for your credentials. Without this key, a new instance can't decrypt stored credentials – so always back it up too.

bash
cd /opt/n8n
# Export workflows and credentials (credentials stay encrypted)
docker compose exec n8n n8n export:workflow --all --output=/home/node/.n8n/backup/workflows.json
docker compose exec n8n n8n export:credentials --all --output=/home/node/.n8n/backup/credentials.json
# Update to the latest version
docker compose pull && docker compose up -d
  • Backup slots: In the MagicHosting dashboard you back up the whole server before updates with up to 5 backup slots.
  • Off-site copy: Regularly copy the exports and the data folder to a second location – the rule behind it is explained in server backups with the 3-2-1 rule.
  • Updates: Read n8n's release notes before major version jumps and test the update after a backup.

Frequently asked questions

How much RAM does n8n need?

Simple workflows run with 2–4 GB RAM. Large data volumes, many parallel executions and code nodes need more. You'll find recommended sizes with live prices on n8n hosting.

SQLite or PostgreSQL?

By default n8n stores data in SQLite inside the data folder – perfectly fine to start with. For teams and high load, switch to PostgreSQL; the required DB_ variables are in the n8n documentation.

Do webhooks work from outside?

Yes. Your server has a fixed public IPv4 address. What matters is that WEBHOOK_URL points to your HTTPS address – otherwise n8n generates webhook links with localhost.

May I use n8n commercially?

n8n is licensed under the Sustainable Use License. Automations within your own company are usually covered; if you want to offer n8n as a service to others, check the licence terms first.

Was this post helpful?

MagicHosting – Hosting with real value

Hosting pays off with MagicHosting: fair pricing, current deals and operation in SkyLink RZ. Servers, domains and personal support – no hidden costs.

  • Current limited offers from our server exchange
  • Affordable domains with transparent pricing and great offers
  • Powerful DDoS protection for maximum availability
  • Personal support when you have questions or issues