Complete Guide to Self-Hosting n8n: Choose Your Deployment Strategy
One of n8n's biggest advantages is the ability to self-host your automation platform. This gives you complete data control, eliminates per-workflow pricing, and enables HIPAA, GDPR, and other compliance requirements. In this guide, we'll walk through three popular deployment options: Docker, AWS, and Kubernetes.
Why Self-Host n8n?
- Data Privacy: Your data never leaves your infrastructure
- Cost Efficiency: No per-execution pricing—run unlimited workflows
- Compliance: Meet HIPAA, GDPR, SOC 2, and other regulatory requirements
- Customization: Full control over resources, security, and integrations
- No Vendor Lock-in: Own your automation infrastructure completely
Prerequisites
Before starting, ensure you have:
- Basic command-line knowledge
- A server or cloud account (AWS, GCP, DigitalOcean, etc.)
- A domain name (for SSL/HTTPS)
- Basic understanding of Docker (for containerized deployments)
Option 1: Docker Deployment (Simplest)
Docker is the fastest way to get n8n running. Perfect for small teams and testing environments.
Step 1: Install Docker
On Ubuntu/Debian:
sudo apt update sudo apt install docker.io docker-compose -y sudo systemctl start docker sudo systemctl enable docker
Step 2: Create Docker Compose File
Create a file named docker-compose.yml:
version: '3.8'
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=your_secure_password
- N8N_HOST=your-domain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://your-domain.com/
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Step 3: Start n8n
docker-compose up -d
Access n8n at http://your-server-ip:5678
Option 2: AWS Deployment
For production workloads, AWS provides reliability and scalability. We recommend using EC2 with RDS for the database.
Architecture Overview
- EC2 Instance: t3.medium or larger for production
- RDS PostgreSQL: Managed database for reliability
- Application Load Balancer: For SSL termination and high availability
- S3: Optional file storage for attachments
Step 1: Launch EC2 Instance
- Choose Amazon Linux 2 or Ubuntu 22.04 LTS
- Select t3.medium (2 vCPU, 4GB RAM) minimum
- Configure security group: Allow ports 22 (SSH), 80, 443
- Add a 30GB+ EBS volume
Step 2: Set Up RDS PostgreSQL
- Create a PostgreSQL instance (db.t3.micro for testing, db.t3.small+ for production)
- Enable automated backups
- Place in private subnet, allow access from EC2 security group
Step 3: Install n8n on EC2
SSH into your instance and run:
# Install Node.js curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs # Install n8n globally sudo npm install -g n8n # Create environment file export DB_TYPE=postgresdb export DB_POSTGRESDB_HOST=your-rds-endpoint export DB_POSTGRESDB_DATABASE=n8n export DB_POSTGRESDB_USER=n8nuser export DB_POSTGRESDB_PASSWORD=your_password
Step 4: Set Up as System Service
Create a systemd service for automatic startup:
sudo nano /etc/systemd/system/n8n.service
Add the service configuration and enable it with sudo systemctl enable n8n.
Option 3: Kubernetes Deployment
For enterprise-scale deployments, Kubernetes provides auto-scaling, high availability, and easy updates.
Prerequisites
- Kubernetes cluster (EKS, GKE, or self-managed)
- kubectl configured
- Helm installed
Deploy Using Helm
# Add n8n Helm repository helm repo add n8n https://n8n-io.github.io/n8n-helm-chart helm repo update # Install n8n helm install n8n n8n/n8n --set n8n.encryption_key=your-encryption-key --set postgresql.enabled=true --set ingress.enabled=true --set ingress.hostname=n8n.your-domain.com
Kubernetes Best Practices
- Use persistent volumes for data storage
- Configure horizontal pod autoscaling
- Set up proper resource limits and requests
- Implement network policies for security
- Use secrets management for credentials
Security Considerations
Regardless of deployment method:
- Enable Authentication: Always enable basic auth or OAuth
- Use HTTPS: Set up SSL certificates (Let's Encrypt is free)
- Firewall Rules: Restrict access to necessary ports only
- Regular Updates: Keep n8n and dependencies updated
- Backup Strategy: Implement automated backups of your database
- Monitoring: Set up alerts for failures and resource usage
Maintenance & Updates
Docker Updates
docker-compose pull docker-compose up -d
NPM Updates
sudo npm update -g n8n sudo systemctl restart n8n
Kubernetes Updates
helm upgrade n8n n8n/n8n --reuse-values
Need Professional n8n Hosting?
Self-hosting n8n requires ongoing maintenance, security updates, and monitoring. Our n8n automation services include fully managed hosting options:
- Deployment and configuration on your infrastructure
- Security hardening and compliance setup
- Monitoring and alerting
- Regular updates and maintenance
- 24/7 support for critical issues
Contact us to discuss your n8n hosting needs.
0 comments