How to Self-Host n8n: Step-by-Step Guide
Introduction
n8n (pronounced "n-eight-n") is a powerful open-source workflow automation tool that allows you to connect different apps, APIs, and services — similar to Zapier or Make (Integromat), but fully customizable and self-hostable.
By self-hosting n8n, you gain:
-
Full control over your data
-
Unlimited workflows and executions
-
Custom integrations and scalability
-
No vendor lock-in
Prerequisites
Before you start, make sure you have:
Basic knowledge of the command line
A server (VPS or cloud instance) with at least:
1 GB RAM (2 GB recommended), 10 GB disk space
Docker and Docker Compose installed
A domain name (optional but recommended for HTTPS)
Node.js (if you plan to install manually)
Installation Methods Overview
There are three common ways to self-host n8n:
-
Using Docker (Recommended)
-
Using npm (Node.js)
-
Using a Cloud Provider (e.g., Railway, Render, etc.)
Installing n8n with Docker Compose
Step 1: Create a Project Directory
docker-compose.yml FileStart the Container
docker-compose up -d
Step 4: Access n8n
Open your browser and visit:
👉 http://localhost:5678
Log in using your credentials (admin / yourpassword).
Setting Up HTTPS (Optional but Recommended)
If you have a domain, you can enable HTTPS using Traefik or NGINX Reverse Proxy.
Example (with Traefik):
n8n:
image: n8nio/n8n
environment:
- N8N_HOST=yourdomain.com
- N8N_PROTOCOL=https
- WEBHOOK_TUNNEL_URL=https://yourdomain.com/
labels:
- "traefik.enable=true"
- "traefik.http.routers.n8n.rule=Host(`yourdomain.com`)"
- "traefik.http.routers.n8n.entrypoints=websecure"
- "traefik.http.routers.n8n.tls.certresolver=letsencrypt"
This setup automatically generates a free SSL certificate using Let’s Encrypt.
Persistent Data Storage
All workflow data is stored in the /home/node/.n8n directory inside the container.
In the Docker Compose file, this directory is mapped to your local machine via:
volumes:
- ./n8n_data:/home/node/.n8n
This ensures your workflows persist even if the container restarts or updates.
Updating n8n
To update to the latest version:
docker-compose pull
docker-compose up -d
Your data and workflows remain safe in n8n_data.
Backup and Restore
Backup
Simply back up your n8n_data folder:
tar -czvf n8n_backup.tar.gz ./n8n_data
Restore
Extract the backup to the same directory:
tar -xzvf n8n_backup.tar.gz -C ./n8n_data
Then restart the container.
Common Issues & Solutions
Conclusion
Self-hosting n8n empowers you to automate tasks securely and flexibly — all under your control. Whether for business operations, app integrations, or personal productivity, n8n can be your central automation hub.
With Docker Compose, installation and management are straightforward, and you can scale up as your workflows grow.