Self-hosting N8N gives you unlimited workflows, complete data control, and massive cost savings compared to cloud automation platforms. But the setup process intimidates many people. | self-host N8N
I’ve deployed N8N for dozens of clients, and I’m going to walk you through the exact process I use—from a completely blank server to a secure, production-ready N8N instance.

Why Self-Host N8N?
Before we dive into technical details, let’s confirm this is right for you.
Self-hosting makes sense if you:
- Run more than 5,000 operations monthly (saves $50+ monthly vs cloud platforms)
- Handle sensitive data requiring on-premise control
- Need custom integrations or modifications
- Want unlimited workflows without per-workflow pricing
- Have basic command-line comfort (or willing to learn)
Stick with N8N Cloud or alternatives if you:
- Want zero maintenance
- Need guaranteed uptime without managing it
- Run fewer than 2,000 operations monthly
- Have no technical team member available
- Can’t dedicate time to initial setup
Still here? Let’s build this.
Choosing Your Server
You need a Virtual Private Server (VPS). Here are proven options:
DigitalOcean ($6-12/month): Best for beginners. Simple interface, great documentation, reliable performance. Recommended: Basic Droplet with 2GB RAM
Hetzner ($5-8/month): Best value. European servers, excellent performance per dollar. Recommended: CX21 or CPX11
AWS Lightsail ($10-20/month): Best for enterprises already using AWS ecosystem. Recommended: 2GB instance
Linode ($10-12/month): Solid middle ground. Good performance, responsive support. Recommended: Nanode 2GB
For starting out, I recommend DigitalOcean. The rest of this guide assumes you’re using it, but the process is similar across providers.
Server Requirements
Minimum specifications:
- 2GB RAM (4GB recommended for heavy use)
- 1 CPU core (2 cores recommended)
- 20GB SSD storage
- Ubuntu 22.04 LTS operating system
Don’t skimp on RAM. N8N with several workflows can consume 1-1.5GB easily.
Step 1: Server Setup and Security
Create your droplet/server with Ubuntu 22.04. Once it’s running, SSH in:
ssh root@your_server_ip
First, update everything:
apt update && apt upgrade -y
Create a non-root user for security:
adduser n8n
usermod -aG sudo n8n
Set up firewall:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
From now on, use the n8n user, not root.
Step 2: Install Docker
N8N runs best in Docker. It’s cleaner, easier to maintain, and simpler to upgrade.
Install Docker:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker n8n
Log out and back in for group changes to take effect.
Install Docker Compose:
sudo apt install docker-compose -y
Verify installation:
docker --version
docker-compose --version
Step 3: Set Up N8N with Docker Compose
Create a directory for N8N:
mkdir n8n-docker
cd n8n-docker
Create a docker-compose.yml file:
yaml
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=change_this_password
- N8N_HOST=your_domain.com
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://your_domain.com/
volumes:
- ~/.n8n:/home/node/.n8n
Replace change_this_password with a strong password and your_domain.com with your actual domain (we’ll set this up next).
Step 4: Domain and SSL Setup
You need a domain name pointing to your server. Use Namecheap, Google Domains, or any registrar.
Add an A record pointing to your server’s IP address.
Install Nginx:
sudo apt install nginx -y
Install Certbot for free SSL certificates:
sudo apt install certbot python3-certbot-nginx -y
Create Nginx configuration for N8N:
sudo nano /etc/nginx/sites-available/n8n
Add this configuration:
nginx
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
Enable the site:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Get SSL certificate:
sudo certbot --nginx -d your_domain.com
Certbot will automatically configure SSL. Choose option 2 to redirect HTTP to HTTPS.
Step 5: Launch N8N
Start N8N:
cd ~/n8n-docker
docker-compose up -d
Check if it’s running:
docker-compose ps
Visit https://your_domain.com in your browser. You should see the N8N login screen!
Step 6: Configure Backups
Never skip backups. N8N stores everything in ~/.n8n/, so back this up regularly.
Create a backup script:
bash
#!/bin/bash
BACKUP_DIR="/home/n8n/backups"
mkdir -p $BACKUP_DIR
tar -czf $BACKUP_DIR/n8n-backup-$(date +%Y%m%d-%H%M%S).tar.gz ~/.n8n/
# Keep only last 7 backups
ls -t $BACKUP_DIR/n8n-backup-*.tar.gz | tail -n +8 | xargs rm -f
Save as backup-n8n.sh, make executable:
chmod +x backup-n8n.sh
Schedule daily backups with cron:
crontab -e
Add this line:
0 2 * * * /home/n8n/backup-n8n.sh
This backs up daily at 2 AM, keeping the last 7 backups.
Step 7: Production Optimizations
Increase Docker Resources:
Edit docker-compose.yml to add memory limits:
yaml
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 1G
Enable Execution Data Pruning:
Add to environment variables:
yaml
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
This deletes execution logs older than 7 days, preventing database bloat.
Set Up Monitoring:
Use Uptime Robot or similar to monitor your N8N instance and alert you if it goes down.
Step 8: Updating N8N
When new versions release:
cd ~/n8n-docker
docker-compose pull
docker-compose down
docker-compose up -d
Always check the N8N changelog for breaking changes before updating.
Troubleshooting Common Issues
N8N won’t start: Check logs: docker-compose logs n8n
Webhooks not working: Verify WEBHOOK_URL is set correctly in docker-compose.yml
Out of memory errors: Upgrade to a server with more RAM or optimize workflows
SSL certificate renewal fails: Ensure ports 80 and 443 are open and Nginx is running
Can’t access N8N: Check firewall: sudo ufw status Verify Nginx is running: sudo systemctl status nginx
Security Best Practices
Change default passwords immediately Enable two-factor authentication if using N8N’s user management Regularly update both N8N and the underlying server Restrict SSH access to specific IP addresses if possible Monitor logs for unusual activity Use strong encryption keys for N8N’s encryption features
Advanced: Multi-User Setup
For teams, set up proper user management:
yaml
- N8N_USER_MANAGEMENT_DISABLED=false
This enables N8N’s built-in user management system.
Cost Breakdown
Monthly costs for self-hosted N8N:
- Server: $6-12
- Domain: $1-2 (annual cost divided by 12)
- Backups (optional offsite): $2-5
- Total: $9-19/month
Compare to cloud platforms charging $50-200+ for similar workflow volumes.
When to Upgrade Your Server
Upgrade if you experience:
- Workflows timing out regularly
- High memory usage (consistently over 80%)
- Slow execution times
- Server unresponsiveness
Simply resize your server in your hosting dashboard—most providers allow this with minimal downtime.
The Bottom Line
Self-hosting N8N requires initial time investment, but the payoff is substantial. You get unlimited automation power at a fraction of cloud platform costs.
The process looks long in this guide, but actual setup time is 1-2 hours. Ongoing maintenance is minimal—maybe 30 minutes monthly for updates.
If you handle sensitive data or run heavy automation, self-hosting isn’t just cheaper—it’s better.
Ready to take control of your automation infrastructure? Start today.