On this page
- What should the server look like for n8n?
- How do you write the Compose file?
- How do you start n8n and confirm the version?
- How do you put Nginx and HTTPS in front?
- What happens on the first visit?
- How do you set up mail for invitations?
- How do you back up workflows and credentials?
- How do you update n8n?
- What goes wrong most often?
- Questions
What should the server look like for n8n?
n8n is a Node.js application; idle it uses a few hundred megabytes, and memory climbs with the size of the data passing through each workflow. A 2 GB plan handles typical business automations, and 4 GB suits workflows that move large files or run many executions in parallel.
- Ubuntu 24.04, Ubuntu 22.04, Debian 12 or Debian 13 with Docker and the Compose plugin (install steps).
- A hostname, for example
n8n.example.net, with A and AAAA records. - Your firewall allowing only SSH, 80 and 443; see UFW.
How do you write the Compose file?
Create /opt/n8n and generate two secrets: one for the database and one for credential encryption.
sudo mkdir -p /opt/n8n && cd /opt/n8n
openssl rand -hex 24
openssl rand -hex 32Then write /opt/n8n/compose.yaml:
services:
postgres:
image: postgres:16
restart: unless-stopped
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: db-secret-here
POSTGRES_DB: n8n
volumes:
- pg_data:/var/lib/postgresql/data
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: unless-stopped
depends_on:
- postgres
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: db-secret-here
N8N_HOST: n8n.example.net
N8N_PORT: 5678
N8N_PROTOCOL: https
WEBHOOK_URL: https://n8n.example.net/
N8N_PROXY_HOPS: 1
N8N_ENCRYPTION_KEY: encryption-secret-here
GENERIC_TIMEZONE: Europe/Berlin
TZ: Europe/Berlin
volumes:
- n8n_data:/home/node/.n8n
volumes:
pg_data:
n8n_data:N8N_ENCRYPTION_KEY protects every stored credential. Write it down somewhere safe: if it is lost, saved credentials cannot be decrypted, even from a backup. N8N_PROXY_HOPS tells n8n to trust one reverse proxy for client addresses.
How do you start n8n and confirm the version?
cd /opt/n8n
sudo docker compose up -d
sudo docker compose ps
sudo docker compose exec n8n n8n --version
curl -sI http://127.0.0.1:5678/healthzThe health endpoint answers with HTTP 200 once the editor is up. Logs are available with sudo docker compose logs -f n8n.
How do you put Nginx and HTTPS in front?
The editor relies on a WebSocket push connection, and webhooks can carry large bodies, so the proxy needs upgrade headers, a higher body limit and buffering switched off.
server {
listen 80;
listen [::]:80;
server_name n8n.example.net;
client_max_body_size 50m;
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-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_read_timeout 300s;
}
}sudo nano /etc/nginx/sites-available/n8n
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d n8n.example.netIf Certbot is not installed yet, see the Certbot guide. Caddy works just as well with a one-line reverse_proxy 127.0.0.1:5678.
What happens on the first visit?
Browse to https://n8n.example.net and n8n asks you to create the owner account, which becomes the instance administrator. Use a strong password and turn on two-factor authentication in your personal settings. From the owner account you can invite more users once mail works.
Test a webhook straight away: add a Webhook node, copy its production URL, activate the workflow and call it with curl -X POST https://n8n.example.net/webhook/test-path. If the URL shown in the node starts with http://localhost, WEBHOOK_URL is missing or wrong.
How do you set up mail for invitations?
n8n mails user invitations and password reset links. Instead of sending straight to port 25, which you should only plan for after asking support in a ticket, point it at an authenticated relay on port 587 (details in the SMTP relay guide). Add these lines under environment:
N8N_EMAIL_MODE: smtp
N8N_SMTP_HOST: smtp.relay.example.net
N8N_SMTP_PORT: 587
N8N_SMTP_USER: n8n@example.net
N8N_SMTP_PASS: relay-password
N8N_SMTP_SENDER: n8n@example.net
N8N_SMTP_SSL: "false"With SSL set to false, n8n upgrades the port 587 connection through STARTTLS. Apply the change with sudo docker compose up -d. Workflows that send mail use their own Send Email node credentials and can use the same relay.
How do you back up workflows and credentials?
Two layers work well together. First, a database dump of everything:
cd /opt/n8n
sudo docker compose exec -T postgres pg_dump -U n8n n8n | gzip > n8n-$(date +%F).sql.gzSecond, the n8n CLI exports workflows and encrypted credentials as JSON files, handy for version control:
sudo docker compose exec n8n n8n export:workflow --backup --output=/home/node/.n8n/backups/workflows/
sudo docker compose exec n8n n8n export:credentials --backup --output=/home/node/.n8n/backups/credentials/Keep the encryption key with the backup, stored separately. The daily backup add-on adds a whole-disk copy on top.
How do you update n8n?
n8n releases often. Read the release notes for breaking changes, then:
cd /opt/n8n
sudo docker compose pull n8n
sudo docker compose up -d
sudo docker compose exec n8n n8n --versionFor production, pin a version tag such as a specific 1.x or 2.x release instead of latest, and step through major versions one at a time, following the migration notes for each.
What goes wrong most often?
- Editor shows "Connection lost": WebSocket headers are missing in the proxy.
- Webhooks return 404: the workflow is not active, or you called the test URL while the editor was not listening.
- Credentials fail to decrypt after a move: the new server uses a different
N8N_ENCRYPTION_KEY. - Memory errors on big files: split the data into batches or move to a larger plan following move to a larger plan.
For a wider view of running your own apps, see self-hosting.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
| Plan | Fits because | Size | Monthly | Order from |
|---|---|---|---|---|
| A1-2 | personal automations and webhooks | 1 vCPU, 2 GB RAM, 50 GB NVMe | $7.20/mo | $43.20 for 6 months |
| A2-4 | team workflows with larger payloads | 2 vCPU, 4 GB RAM, 100 GB NVMe | $14.40/mo | $43.20 for 3 months |
| A4-8 | heavy file processing or many parallel runs | 4 vCPU, 8 GB RAM, 180 GB NVMe | $28.80/mo | $86.40 for 3 months |
Questions about n8n workflow automation
Is n8n free to self-host?
The community edition is source-available under the Sustainable Use License and can be self-hosted for internal business use. Some team features need a paid license key.
Do I need PostgreSQL, or is SQLite enough?
SQLite is the default and fine for a single user. PostgreSQL copes better with many executions and is easier to back up while running.
Why does my webhook URL say localhost?
Set WEBHOOK_URL to the public HTTPS address and recreate the container.
Can n8n run code?
Yes. The Code node runs JavaScript, and Python in recent versions through task runners. Treat workflow editors as trusted users for that reason.
How do I stop old executions filling the disk?
Execution pruning is on by default; adjust EXECUTIONS_DATA_MAX_AGE (hours) and EXECUTIONS_DATA_PRUNE to keep less history.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM