Skip to content
zefıly
← All posts

Self-hosting n8n on your own server: Docker, HTTPS and backups

5 min read

How to run n8n on a VPS with Docker. The settings that webhooks need, the encryption key you must not lose, the reverse proxy configuration, memory use, backups and updates. Tested with n8n 2.47.

n8n is a workflow automation tool that you can run yourself. On your own server there is no limit on workflows or executions, and your credentials stay with you. The price is that you run it: HTTPS, backups and updates are your job.

We tested the commands here on 12 November 2026 with the official image, which was n8n 2.47.5 that day.

In short

  • One container, one volume. n8n keeps everything in /home/node/.n8n, in SQLite by default.
  • Set WEBHOOK_URL to your public address, or webhooks show the wrong URL.
  • Set N8N_ENCRYPTION_KEY yourself and keep a copy. Without it, saved credentials cannot be read.
  • Give it memory: our idle container used about 520 MB.
  • Put it behind a reverse proxy with HTTPS, and create the owner account before anyone else does.

1. What the server needs

A VPS with 2 GB of memory is a sensible minimum; n8n is a Node.js application and used about 520 MB in our test before running a single workflow. You need Docker (or Podman), a domain name pointing at the server, and a web server for HTTPS.

2. Start the container

docker volume create n8n_data

docker run -d --name n8n --restart unless-stopped \
  -p 127.0.0.1:5678:5678 \
  -e N8N_HOST=n8n.example.com \
  -e N8N_PROTOCOL=https \
  -e WEBHOOK_URL=https://n8n.example.com/ \
  -e GENERIC_TIMEZONE=Europe/Istanbul \
  -e N8N_ENCRYPTION_KEY=<a long random string> \
  -v n8n_data:/home/node/.n8n \
  docker.io/n8nio/n8n:2.47.5

Three details matter:

  • 127.0.0.1:5678, not 5678. The container is reachable only from the server itself; the web server in front adds HTTPS. Publishing the port to the internet would expose n8n without encryption.
  • A fixed version tag. :latest changes under you. Pin a version and update on purpose.
  • WEBHOOK_URL. n8n runs behind a proxy and cannot know its public address. Without this setting, the webhook URLs it shows start with http://localhost:5678.

Check that it runs:

curl http://127.0.0.1:5678/healthz
{"status":"ok"}

3. The encryption key

n8n encrypts the credentials you save (API keys, passwords, OAuth tokens) with one key. If you do not set N8N_ENCRYPTION_KEY, n8n makes one on first start and stores it in the config file in the data volume.

Set it yourself and keep a copy outside the server. If the key is lost or changes, every saved credential becomes unreadable, and you enter them all again.

Generate one with:

openssl rand -hex 32

4. Reverse proxy

n8n's editor uses a persistent connection to the server, so the proxy must pass WebSocket upgrades. For nginx:

server {
    server_name n8n.example.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_read_timeout 300s;
    }
}

Then get a certificate, for example with Certbot.

5. First visit

Open the site and create the owner account on the setup screen. Do this right away: until an owner exists, whoever opens the address first becomes the owner.

If only you and your team use the editor, restrict it further: allow your IP addresses only, or add a password in front. Webhooks must stay reachable, so limit the editor paths, not /webhook/.

6. What is in the volume

config  database.sqlite  ...
  • database.sqlite: workflows, credentials (encrypted), execution history.
  • config: settings, including the encryption key if n8n created it.

The container runs as the user node (uid 1000). If you mount a host directory instead of a volume, it must belong to that uid, or n8n stops with a permission error.

SQLite is fine for one instance with moderate use. For many executions per minute, n8n supports PostgreSQL.

7. Backups

Back up the volume and your encryption key. Stop the container for a moment for a consistent copy:

docker stop n8n
docker run --rm -v n8n_data:/data -v "$PWD":/backup alpine \
  tar czf /backup/n8n-$(date +%F).tar.gz -C /data .
docker start n8n

Copy the archive off the server. Execution history makes the database grow; set a retention period in n8n's settings so that it does not fill the disk.

8. Updates

docker pull docker.io/n8nio/n8n:<new version>
docker stop n8n && docker rm n8n
# run the same docker run command with the new tag

The data stays in the volume. n8n migrates its database when the new version starts. Back up first, and read the release notes before a new major version: they list breaking changes.

With Zefily

n8n is a one-click app in Zefily. It runs as a rootless container under the site's own Linux user, on 127.0.0.1 behind the web server with HTTPS. Zefily sets N8N_HOST, WEBHOOK_URL and a generated N8N_ENCRYPTION_KEY for you, keeps the data in a volume that survives updates, and shows a First step notice until you have created the owner account. See Container apps.

Frequently asked questions

How much memory does n8n need?

In our test an idle n8n 2.47.5 container used about 520 MB. A server with 2 GB of memory is a sensible minimum.

Why do my n8n webhook URLs show localhost?

Because n8n does not know its public address behind a proxy. Set WEBHOOK_URL to your https address and restart the container.

What happens if I lose the n8n encryption key?

The saved credentials cannot be decrypted any more and must be entered again. Set N8N_ENCRYPTION_KEY yourself and keep a copy outside the server.

Where does n8n store its data?

In /home/node/.n8n inside the container: database.sqlite with workflows, credentials and execution history, and the config file.

Does n8n need a database server?

No. It uses SQLite by default. PostgreSQL is supported for larger installations.

See Containers for running your own images with Zefily.

More posts

Black Friday & Cyber Monday

Before you go: lifetime plans are on sale

Pay once for a lifetime plan, or get 30% off the first year of any yearly plan.

Only 100 lifetime plans per plan. When they are gone, they are gone.

See the campaign

Amazing November

See the campaign →