n8n Self-Hosted Guide — Run Your Own Automation Platform on a VPS
n8n Self-Hosted Guide — Run Your Own Automation Platform on a VPS
n8n is one of the most powerful open-source workflow automation platforms, allowing you to build integrations, API orchestrations, background jobs, data pipelines, AI workflows, business automations and more — without paying per task like Zapier or Make.
Self-hosting n8n means:
✔ Full data control
✔ Unlimited execution
✔ Lower long-term cost
✔ Enterprise-grade extensibility
In this guide, you’ll learn how to deploy and run n8n self-hosted on a VPS, configure environment variables, enable SSL, and build your first workflow.
💡 Tip: If you don’t have a VPS yet, choose something stable with good network performance. Many developers like using LightNode VPS because it’s affordable, fast, and works great for automation workloads.
Requirements
- A VPS (Ubuntu 20.04+ recommended)
- SSH access
- Docker installed (recommended method)
- Domain (optional but recommended)
- Basic Linux knowledge
1. Connect to Your VPS
ssh root@your-server-ipUpdate system:
apt update && apt upgrade -y2. Install Docker & Docker Compose
apt install docker.io docker-compose -y
systemctl enable docker
systemctl start dockerVerify:
docker --version3. Deploy n8n (Docker)
Create directory:
mkdir /opt/n8n
cd /opt/n8nCreate docker-compose.yml
version: "3"
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=yourpassword
- N8N_HOST=your-domain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
volumes:
- ./data:/home/node/.n8nRun:
docker-compose up -dCheck status:
docker psNow access:
http://SERVER-IP:56784. Setup Reverse Proxy + SSL (NGINX + Let’s Encrypt)
Install nginx:
apt install nginx -yInstall certbot:
apt install certbot python3-certbot-nginx -yCreate nginx config:
nano /etc/nginx/sites-available/n8nPaste:
server {
server_name your-domain.com;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
}
}Enable:
ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginxAdd SSL:
certbot --nginx -d your-domain.comDone 🚀
Now access:
https://your-domain.com5. Persistent Storage
Your workflows must survive container restarts.
We already mounted:
./data:/home/node/.n8nTo backup:
tar -czvf n8n-backup.tar.gz /opt/n8n/data6. Enable Authentication
Already configured via ENV:
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=yourpasswordThis protects your instance.
7. Create Your First Workflow
Open n8n → Click New Workflow
Example: Webhook → Send HTTP Request
Add Webhook Node
Trigger URL will appear
Choose POSTAdd HTTP Request Node
Set URL to API endpoint
Example:
https://api.example.com/data- Connect nodes
- Activate workflow
Now send a POST:
curl -X POST https://your-domain.com/webhook/test \
-H "Content-Type: application/json" \
-d '{"status":"ok"}'Workflow runs 🎉
8. System Maintenance
Restart n8n:
docker-compose restartUpdate n8n:
docker-compose pull
docker-compose up -dCheck logs:
docker logs -f container-id9. Performance Recommendations
Minimum 2GB RAM for smooth workflows
Enable swap if low RAM
Use dedicated CPU if possible
Monitor Docker memory usage
Avoid extremely large workflows in single instance
For scale → load balancer + Redis + DB cluster
Common Issues & Fixes
Port 5678 refused
Open firewall:
ufw allow 5678❌SSL fails
Ensure A-record correct
Domain propagated
❌ n8n crashes
Restart:
docker-compose restartCheck logs:
docker logs -f n8nWhy Self-Host n8n?
Compared to Zapier / Make / IFTTT:
No per-task billing
Private data processing
Developer-level power
Customizability
Scalable on VPS infrastructure
If automation becomes long-term production infrastructure, self-hosted n8n on VPS is the best value model.
FAQ
Is self-hosting n8n better than cloud?
If you care about:
cost
privacy
flexibility
then yes.
How much VPS power do I need?
Minimum:
1 vCPU
2GB RAM
SSD storage
More workflows → more resources.
Can I use MySQL/PostgreSQL instead of SQLite?
Yes. Production setups commonly use PostgreSQL.
Does n8n support AI workflows?
Yes. Supports OpenAI, Gemini, Claude, DeepSeek and custom API models.
Is Docker required?
No. You can install Node.js and run manually — but Docker is recommended.
Can multiple users use one n8n instance?
Yes, via credentials and environment isolation.
Recommended Note: If you plan to self-host n8n for long-term automation workloads, a stable and affordable VPS like LightNode VPS is a great option thanks to its reliable performance and global data center coverage.