How to Self-Host n8n on a VPS for Free Workflow Automation

Automation is becoming essential in modern workflows. Whether it’s sending emails, syncing data, or automating tasks, tools like n8n make it easy.
n8n is an open-source alternative to:
- Zapier
- Make (Integromat)
The best part?
👉 You can self-host it for free on your VPS.
In this guide, you’ll learn how to self-host n8n step by step using Docker and Nginx.
What is n8n?
n8n is a workflow automation tool that connects apps and services.
You can automate:
- Emails
- APIs
- Databases
- Cloud services
Why Self-Host n8n?
1. Free Forever
No subscription fees.
2. Full Control
Your data stays on your server.
3. Custom Workflows
No limitations.
Requirements
- VPS (2GB RAM recommended)
- Domain name
- Docker installed
For beginners, I recommend starting with a reliable VPS like DigitalOcean / AWS Lightsail / Cloudways VPS (affordable and easy to set up).
👉 [Get Started with a VPS here]
Step 1: Install Docker
sudo apt update
sudo apt install docker.io docker-compose -y
Enable Docker:
sudo systemctl enable docker
Step 2: Create n8n Directory
mkdir n8n && cd n8n
Step 3: Create 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=strongpassword
Step 4: Start n8n
docker-compose up -d
Step 5: Access n8n
Step 6: Set Up Nginx Reverse Proxy
server {
listen 80;
server_name n8n.yourdomain.com;
location / {
proxy_pass http://localhost:5678;
}
}
Step 7: Enable SSL
sudo certbot --nginx -d n8n.yourdomain.com
Step 8: Secure n8n
- Enable authentication
- Use strong passwords
- Restrict access
Step 9: Backup n8n Data
Mount volume:
volumes:
- ./n8n_data:/home/node/.n8n
Step 10: Create Workflows
Examples:
- Auto email alerts
- Server monitoring
- Backup notifications
Performance Tips
- Use VPS with enough RAM
- Monitor container usage
- Restart periodically
Common Issues
Port Conflict
Change port in config.
Container not starting
Check logs:
docker logs n8n
Best Practices
- Use HTTPS
- Backup workflows
- Monitor logs
FAQs
Is n8n free?
Yes (self-hosted).
Does it replace Zapier?
Yes, for most use cases.
Final Thoughts
Self-hosting n8n on a VPS is one of the best ways to automate workflows without paying monthly fees. It’s powerful, flexible, and perfect for developers and system admins.
