n8n is a workflow automation platform that gives technical teams the flexibility of code with the speed of no-code.
n8n Docker Compose example
Self-host n8n on your own server, homelab, or VPS starting from this Docker Compose example.
It runs n8n in Docker containers using the official n8nio/n8n:latest image, with persistent volumes and automatic restarts preconfigured.
Review the environment variables and adjust them to your setup, save the file as compose.yml (or docker-compose.yml), and start the stack with docker compose up -d.
services:
n8n:
image: n8nio/n8n:latest
volumes:
- data:/home/node/.n8n
restart: unless-stopped
environment:
NODE_ENV: "production"
# The n8n instance timezone. Important for schedule nodes (such as Cron).
GENERIC_TIMEZONE: "UTC"
# A locale identifier, compatible with the Accept-Language header. Falls back to "en" for any untranslated strings.
N8N_DEFAULT_LOCALE: "en"
# A custom key used to encrypt credentials in the n8n database
N8N_ENCRYPTION_KEY: "changeme"
# Used to manually provide the Webhook URL when running n8n behind a reverse proxy.
WEBHOOK_URL: "changeme"
# Public URL where users can access the editor.
N8N_EDITOR_BASE_URL: "changeme"
DB_TYPE: "sqlite"
DB_SQLITE_PATH: "/home/node/.n8n/database.sqlite"
DB_SQLITE_POOL_SIZE: "2"
# Enable emails.
N8N_EMAIL_MODE: "smtp"
# your_SMTP_server_name
N8N_SMTP_HOST: "changeme"
# your_SMTP_server_port
N8N_SMTP_PORT: "changeme"
# your_SMTP_username
N8N_SMTP_USER: "changeme"
# your_SMTP_password
N8N_SMTP_PASS: "changeme"
# Whether to use SSL for SMTP (true) or not (false).
N8N_SMTP_SSL: "true"
# Whether to use STARTTLS for SMTP (true) or not (false).
N8N_SMTP_STARTTLS: "true"
# Sender email address. You can optionally include the sender name. Example with name: N8N <contact@n8n.com>
N8N_SMTP_SENDER: "changeme"
N8N_RUNNERS_ENABLED: "true"
volumes:
data:
Values set to changeme are required — replace them with your own
values before starting n8n.
Prefer a managed setup? WinterFlow installs, configures, and updates n8n for you using this same Docker Compose configuration.