n8n is a leading visual editor for rapid iterations, allowing you to build automation workflows and see results immediately. Perfect for everyday automations and complex AI agent workflows.
Self-hosting support and the low-code editor make n8n a favorite among developers. If you want maximum control, customizations, and long-term cost savings, the self-hosted version is the right choice for you.
Want to self-host n8n? We guide you step-by-step through setup and configuration, showing you everything you need to know.
Although n8n is lightweight, resource usage can increase with the number of workflows, API calls, and data-intensive nodes. We recommend the following hardware specs for your VPS to host n8n:
| Hardware | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU core | 2 vCPU cores |
| RAM | 2 GB | 4 GB |
| Storage | 20 GB | 50 GB |
Once Docker is running on your server, verify the installation with:
docker --version
docker compose version
Create a project directory to store n8n local files and environment variables, then navigate into it:
mkdir n8n-compose
cd n8n-compose
In the n8n-compose directory, create a .env file with nano .env and add the following code with n8n environment variables:
# DOMAIN_NAME and SUBDOMAIN together define the address where n8n is accessible
# The top-level domain
DOMAIN_NAME=zap.cloud
# The subdomain
SUBDOMAIN=silver-octopus-xxxxx
# The example above makes n8n accessible at: https://silver-octopus-xxxxx.zap.cloud
# Optional timezone used by Cron and other scheduling nodes
GENERIC_TIMEZONE=Europe/Berlin
# Email address for TLS/SSL certificate creation
SSL_EMAIL=hello@zap-hosting.com
Hostname.
Enter the part zap.cloud as DOMAIN_NAME and the first part as SUBDOMAIN (e.g., silver-octopus-xxxxx).
HTTPS Requirement Do not use a plain IP address in the .env file. n8n requires an HTTPS connection, and SSL certificates are only issued for domains, not IP addresses.
If you prefer to host n8n on your own domain, create a subdomain for n8n by adding an A record in your domain’s DNS manager pointing to your VPS’s IP.
| Name | Type | Value | TTL | Priority |
|---|---|---|---|---|
| n8n (subdomain) | A | IPv4 address | 1440 | 0 |
Inside the project folder, create another folder named local-files to share files between the n8n instance and the host system:
mkdir local-files
Create the Docker Compose file compose.yaml with nano compose.yaml and add the following content:
services:
traefik:
image: "traefik"
restart: always
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
- "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
- "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- traefik_data:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock:ro
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "127.0.0.1:5678:5678"
labels:
- traefik.enable=true
- traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
- traefik.http.routers.n8n.tls=true
- traefik.http.routers.n8n.entrypoints=web,websecure
- traefik.http.routers.n8n.tls.certresolver=mytlschallenge
- traefik.http.middlewares.n8n.headers.SSLRedirect=true
- traefik.http.middlewares.n8n.headers.STSSeconds=315360000
- traefik.http.middlewares.n8n.headers.browserXSSFilter=true
- traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
- traefik.http.middlewares.n8n.headers.forceSTSHeader=true
- traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
- traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
- traefik.http.middlewares.n8n.headers.STSPreload=true
- traefik.http.routers.n8n.middlewares=n8n@docker
environment:
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- N8N_RUNNERS_ENABLED=true
- NODE_ENV=production
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- TZ=${GENERIC_TIMEZONE}
volumes:
- n8n_data:/home/node/.n8n
- ./local-files:/files
volumes:
n8n_data:
traefik_data:
This installs n8n, issues an SSL certificate, configures it, and makes n8n live on your domain.
Start n8n with:
sudo docker compose up -d
You can stop n8n with:
sudo docker compose stop
After starting, open n8n in your browser via the URL (or hostname if used). You will first need to create an admin account.
Remember your password Keep your password safe for later use!
Then a short survey appears where you enter some basic info.
Optionally, you can get free access to some paid features by entering your email and receiving a license key by mail. If interested, enter your email and request the license key.
The license key arrives immediately by email. Copy it and enter it in Settings > Usage & Plans > Enter Activation Key.
Then you can go straight to the dashboard and start using n8n!
Start with a blank canvas or use a pre-made template. Your n8n installation is ready!
