Skip to main content
To self-host n8n with Docker, point n8n.example.com at your server, create an .env file and the official compose.yaml that runs n8nio/n8n behind Traefik, then run sudo docker compose up -d. Traefik gets a Let’s Encrypt certificate automatically. Open https://n8n.example.com and create the owner account.

What is n8n?

n8n is a workflow automation tool. You connect apps and APIs in a visual editor, for example “when a form is submitted, add a row to a sheet and post to Discord”, and n8n runs the workflow on a trigger or schedule. The self-hosted Community Edition runs on your own server.

Before you start

  • Install Docker. The commands use sudo; leave it out if you are root.
  • Create an A record for n8n.example.com pointing to your server. See point a domain to your server.
  • Ports 80 and 443 must be free, because Traefik uses them. If Nginx already runs on this server, see use Nginx instead of Traefik.
  • The n8n docs do not set a minimum for n8n alone. Their larger setup with the n8n Assistant sandbox asks for at least 4 GB RAM and 2 vCPUs.

How to install n8n with Docker Compose

1

Create the project folders

local-files is shared with n8n as /files, for nodes that read or write files.
2

Create .env

n8n is served at https://SUBDOMAIN.DOMAIN_NAME. GENERIC_TIMEZONE sets the time zone for schedule triggers. Let’s Encrypt uses SSL_EMAIL for expiry notices.
3

Create compose.yaml

This is the file from the official n8n Docker Compose guide:
n8nio/n8n without a tag pulls latest, which n8n describes as the latest stable version. N8N_WEBHOOK_URL needs n8n 2.30.0 or later; older versions use WEBHOOK_URL.
4

Start n8n

5

Create the owner account

Open https://n8n.example.com. n8n shows the owner setup screen: enter your email, name and a strong password. The first person to complete it becomes the instance owner, so do this straight away.
The n8n_data volume holds the SQLite database and the encryption key for every credential you save in n8n. Never delete it without a backup.

How to use Nginx instead of Traefik

If Nginx already serves other sites on ports 80 and 443, delete the whole traefik service and the traefik_data volume from compose.yaml. n8n already listens on 127.0.0.1:5678, so proxy to it as in set up Nginx as a reverse proxy, including the WebSocket Upgrade headers, then run sudo certbot --nginx -d n8n.example.com. Add N8N_PROXY_HOPS=1 to the n8n environment so it trusts the forwarded headers from one proxy.

How to check it worked

Both containers show Up, and curl exits without an error (add -v to see the 200 response). In the browser, the padlock shows a valid certificate.

How to back up n8n

A complete backup is the .n8n folder, which lives in the n8n_data volume. With the default SQLite database, stop n8n first so the copy is consistent:
The volume name is the folder name plus _n8n_data; check it with sudo docker volume ls. To also export workflows and credentials as readable JSON into local-files:
Credentials stay encrypted; you need the key from the .n8n folder to restore them. See the n8n backup guide and back up Docker volumes.

How to update n8n

Back up first, then pull the new image and recreate the containers:
Read the n8n release notes before a major version. To stay on one version, pin a tag such as n8nio/n8n:2.30.0 instead of latest.

Frequently asked questions

Why do webhooks show localhost or the wrong URL?

n8n builds webhook URLs from its settings. Check that N8N_HOST, N8N_PROTOCOL and N8N_WEBHOOK_URL (or WEBHOOK_URL before 2.30.0) match your public HTTPS address, then run sudo docker compose up -d.

Can I use PostgreSQL instead of SQLite?

Yes. n8n recommends PostgreSQL for production instances with more users or workflows running around the clock. Set DB_TYPE=postgresdb and the DB_POSTGRESDB_* variables; the n8n-hosting repository has a ready-made example.

How do I set up email for invites and password resets?

Set N8N_EMAIL_MODE=smtp, N8N_SMTP_HOST, N8N_SMTP_PORT, N8N_SMTP_USER, N8N_SMTP_PASS and N8N_SMTP_SENDER in the n8n environment and recreate the container. Without SMTP, users can’t reset their own passwords.

Why does Traefik fail to get a certificate?

The A record doesn’t point to this server yet, or port 443 is blocked or used by another program. Check with sudo docker compose logs traefik and check open ports on Linux.

VPS and dedicated server guides

Every guide in this section.

Traefik with Docker

How the Traefik labels work.

Docker Compose tutorial

How compose.yaml works.

Update Docker containers

Pull new images safely.

Secure Docker on a VPS

Protect the Docker socket and ports.

Checked against the official n8n self-hosting documentation on 4 November 2026 (image n8nio/n8n); compose.yaml validated with docker compose config on Ubuntu 24.04 LTS. Environment variable names can change between n8n versions.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026