When you self-host n8n, your automations, their credentials and their history run on a machine you control, with the free Community edition. This guide follows the official n8n documentation, from the licence to backups, by way of Docker, PostgreSQL, HTTPS webhooks and queue mode.
By Simon Vasconcelos Lee
Published on 2 December 20269 minute read
N8N_ENCRYPTION_KEY and back it up separately: without it, saved credentials can no longer be decrypted.N8N_WEBHOOK_URL, behind a reverse proxy.n8n is published under the Sustainable Use License, a "fair-code" licence the company created in 2022: the source code is available, with usage limits that place it outside the OSI’s definition of open source. It allows you to use, modify and redistribute n8n, with three limits. The first, word for word: "You may use or modify the software only for your own internal business purposes or for non-commercial or personal use." The other two: redistribute only free of charge and for non-commercial purposes, and keep the licence notices.
| Allowed by the licence | Requires a commercial agreement with n8n |
|---|---|
| Automating how your company runs | Hosting n8n as a service where your clients build their workflows |
| Delivering automations to your clients on your instance, without them being able to create or modify them | Letting external users configure their workflows (interface, API, MCP, AI agent) |
| Charging for setup, maintenance, training and consulting | Offering n8n as a white-label product |
| Using n8n behind the scenes in your product, with your users triggering your automations | Launching your own automation product on the n8n code |
| Running several instances of the Community edition | Using Enterprise features without a licence |
The Community edition covers almost all of n8n, queue mode included; the paid Business and Enterprise plans add, among other things, SSO, projects, workflow sharing and multi-main mode. For a borderline case, the company’s licence FAQ goes through examples.
n8n recommends Docker for self-hosting: an isolated environment, with no conflicts with the system, and a database and variables that are simple to manage. Here is a minimal Docker Compose base for n8n and PostgreSQL, whose secrets live in a .env file alongside:
services:
postgres:
image: postgres:18
restart: always
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: n8n
PGDATA: /var/lib/postgresql/data
volumes:
- db-storage:/var/lib/postgresql/data
n8n:
image: n8nio/n8n:${N8N_VERSION}
restart: always
ports:
- "127.0.0.1:5678:5678"
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_DATABASE: n8n
DB_POSTGRESDB_USER: n8n
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
N8N_HOST: n8n.example.com
N8N_PROTOCOL: https
N8N_WEBHOOK_URL: https://n8n.example.com/
N8N_PROXY_HOPS: "1"
GENERIC_TIMEZONE: Europe/Paris
TZ: Europe/Paris
volumes:
- n8n-data:/home/node/.n8n
depends_on:
- postgres
volumes:
db-storage:
n8n-data:
N8N_VERSION, in .env, holds the number of the latest stable release; each update becomes a deliberate choice.127.0.0.1: by default, Docker publishes on all of the server’s addresses, ahead of the ufw firewall rules. Bound locally, n8n can only be reached through the reverse proxy./home/node/.n8n volume keeps the configuration and the encryption key, even with PostgreSQL.GENERIC_TIMEZONE for scheduled nodes, TZ for the system.In terms of resources, n8n puts little load on the processor, and memory depends on the workflows: an idle n8n Cloud instance uses about 100 MB, while the Code node and large binary files need much more. The company’s full Docker Compose stack, with the n8n Assistant sandbox, needs at least 4 GB and 2 vCPUs.
The n8n documentation lists what self-hosting involves: installing servers and containers, managing resources and scaling, securing servers and applications, configuring n8n. On a Managed VPS, the host takes on the server share of that list: system and security updates, day-and-night monitoring, backups. It also proactively monitors your instance, errors, slowdowns, disk space, and recommends the fixes, which you apply, yourself or through your AI assistant.
By default, n8n stores workflows, credentials and executions in SQLite, a single file (~/.n8n/database.sqlite). Its documentation considers it suited to trials, and advises PostgreSQL as soon as a production instance serves more than a handful of users or runs workflows continuously. It supports PostgreSQL 16, 17 and 18.
| Criterion | SQLite | PostgreSQL |
|---|---|---|
| Setup | None, the default database | One more service and its DB_POSTGRESDB_* variables |
| Use | Trials, a small instance | Production, continuous executions |
| Queue mode | Outside its scope | Required |
| Backup | A copy of the .n8n folder, with n8n stopped | pg_dump, with n8n running |
An existing SQLite instance moves to PostgreSQL through n8n’s export and import commands, the new database starting empty. With the postgres:18 image, keep the PGDATA line from the example: without it, PostgreSQL 18 stores its data outside the volume.
n8n automatically prunes executions that finished more than 14 days ago, or beyond 10,000. With SQLite, the freed space is reused; to give it back to the disk, enable DB_SQLITE_VACUUM_ON_STARTUP.
A webhook is an address that external services call: n8n must be reachable from the internet. It builds its addresses from N8N_PROTOCOL, N8N_HOST and N8N_PORT, whereas the public arrives through the proxy, on port 443. Its documentation calls for three settings:
N8N_WEBHOOK_URL, the public address, which n8n displays in the editor and registers with external services (WEBHOOK_URL before version 2.30);N8N_PROXY_HOPS=1, for one proxy in front of n8n;X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto headers, set by the proxy.server {
listen 80;
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-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
HTTPS is a must from the start: by default, n8n sends its cookies over HTTPS only (N8N_SECURE_COOKIE=true). sudo certbot --nginx installs the Let's Encrypt certificate, which Certbot then renews on its own. The Upgrade and Connection headers serve the editor, which receives its updates over WebSocket.
On a single instance, n8n handles up to 220 workflow executions per second, according to the company’s measurements. The first limit usually comes from memory: each node fetches as much data as it asks for, and binary files stay in memory by default. The company’s advice: N8N_DEFAULT_BINARY_DATA_MODE=filesystem to write those files to disk, batches of 200 rows rather than 10,000, the Code node kept for what truly needs it, sub-workflows, or more memory.
Queue mode, included in the Community edition, then separates the roles: the main instance receives triggers and webhooks, Redis holds the execution queue, and workers run the executions.
| Setting | Where | Role |
|---|---|---|
EXECUTIONS_MODE=queue | Main instance and workers | Turns on queue mode |
QUEUE_BULL_REDIS_HOST, QUEUE_BULL_REDIS_PORT | Main instance and workers | Redis address, localhost:6379 by default |
N8N_ENCRYPTION_KEY | Everywhere, identical | Lets workers read the credentials |
n8n worker --concurrency=10 | Each worker | Parallel executions: 10 by default, at least 5 recommended |
This mode relies on PostgreSQL, and binary files move into the database (N8N_DEFAULT_BINARY_DATA_MODE=database) rather than onto one instance’s disk. For very large volumes of incoming calls, dedicated webhook processes, behind a load balancer, complete the setup.
n8n encrypts saved credentials (API keys, passwords, tokens) with a key generated at first launch and stored in the config file of the .n8n folder. Without that key, or without the same N8N_ENCRYPTION_KEY, a restored database or a credentials export can no longer be decrypted. Set the key before the first launch, and keep a copy of it separately, in a password manager.
A complete backup brings together:
.n8n folder (the n8n-data volume), with the key and, under SQLite, the database: stop n8n before copying it, for a consistent copy;pg_dump;docker compose exec -T postgres pg_dump -U n8n -Fc n8n > n8n-$(date +%F).dump
docker compose exec n8n n8n export:workflow --backup --output=/home/node/.n8n/backups/workflows/
docker compose exec n8n n8n export:credentials --backup --output=/home/node/.n8n/backups/credentials/
The exports cover workflows and credentials, still encrypted with the key; users, execution history, variables and settings stay in the database. They therefore complement its backup. A reimported workflow arrives deactivated.
n8n publishes a minor version almost every week. Its documentation advises updating at least once a month, to avoid big jumps, reading the release notes to spot breaking changes, and trying first on a test instance. With Docker Compose, change N8N_VERSION in .env, then:
docker compose pull
docker compose down
docker compose up -d
Schedule the update for a quiet hour: during the restart, a webhook that gets called receives an error.
With a Simafri Managed VPS, our teams keep your n8n instance’s server up to date, monitor it day and night and step in without waiting for your call; they also proactively monitor your instance and recommend useful fixes, which you apply, yourself or through your AI assistant. Backups are encrypted every night and kept off the machine, restores are included, and migrating your current server is free.
Yes. The self-hosted Community edition is free for the company’s internal business purposes, under the Sustainable Use License. You can also deliver automations to your clients and charge for setting them up, as long as they can neither create nor modify the workflows.
SQLite, the default database, is fine for trials. For a production instance with several users or workflows running continuously, the n8n documentation advises PostgreSQL (versions 16, 17 and 18), which queue mode also requires.
Saved credentials can no longer be decrypted, neither in a restored database nor in an export: they have to be re-entered one by one. The key is in the config file of the .n8n folder, or in N8N_ENCRYPTION_KEY if you set it: back it up separately.
n8n builds its webhook addresses from N8N_PROTOCOL, N8N_HOST and N8N_PORT. Behind a reverse proxy, declare the public address in N8N_WEBHOOK_URL (WEBHOOK_URL before version 2.30) and set N8N_PROXY_HOPS=1.
Simafri
Let's talk about your project
Tell us what you need in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.