Self-hosting n8n
This section provides guidance on setting up n8n for both the Enterprise and Community self-hosted editions. The Community edition is free, the Enterprise edition isn't.
⚠️ Important: This GitHub Pages site hosts documentation only. To actually run n8n, you need a server with Node.js or Docker. GitHub Pages cannot host backend applications.
Installation and server setups
Install n8n on any platform using npm or Docker. Or follow our guides to popular hosting platforms.
Quick Start - Local Testing
Try n8n locally on your computer first:
- Using npx (easiest):
npx n8n
- Using npm:
npm install n8n -g && n8n
- Using Docker:
docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n
After starting, open http://localhost:5678
in your browser.
Production Hosting Platforms
For production use, host n8n on a cloud platform:
- DigitalOcean: One-click n8n droplet available
- Railway: Deploy with git integration
- AWS EC2: Full control, requires setup
- Heroku: Quick deployment with add-ons
- Google Cloud Run: Serverless container hosting
- Azure: Container instances or App Service
Docker Production Setup (Recommended)
Create a docker-compose.yml
file:
version: '3.8'
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- N8N_HOST=yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://yourdomain.com/
- GENERIC_TIMEZONE=America/New_York
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Then run: docker-compose up -d
Step-by-Step: Deploy to DigitalOcean
- Create a DigitalOcean account
- Create a new Droplet (Ubuntu 22.04 LTS, minimum $6/month)
- SSH into your droplet:
ssh root@your-droplet-ip
- Install Docker:
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
- Install Docker Compose:
apt install docker-compose -y
- Create the docker-compose.yml file (see above)
- Start n8n:
docker-compose up -d
- Configure firewall:
ufw allow 5678 && ufw enable
- Access n8n at
http://your-droplet-ip:5678
- Set up SSL with Caddy or Nginx (see Security section)
Step-by-Step: Deploy to Railway
- Create a Railway account
- Click "New Project" → "Deploy from Docker Image"
- Use image:
n8nio/n8n:latest
- Add environment variables:
N8N_PORT=5678
N8N_PROTOCOL=https
WEBHOOK_URL=https://your-app.railway.app/
- Add a volume:
/home/node/.n8n
- Deploy and wait for the URL to be generated
Configuration
Learn how to configure n8n with environment variables.
Essential Environment Variables
N8N_HOST
- The host on which n8n should be reachable (e.g.,n8n.yourdomain.com
)N8N_PORT
- The port n8n should run on (default:5678
)N8N_PROTOCOL
- The protocol:http
orhttps
(use https in production)WEBHOOK_URL
- The URL for webhook calls (e.g.,https://n8n.yourdomain.com/
)GENERIC_TIMEZONE
- Your timezone (e.g.,America/New_York
,Europe/London
)NODE_ENV
- Set toproduction
for production deployments
Database Configuration (PostgreSQL)
For production, use PostgreSQL instead of SQLite:
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=localhost
DB_POSTGRESDB_PORT=5432
DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=n8n
DB_POSTGRESDB_PASSWORD=your_secure_password
Authentication Configuration
N8N_BASIC_AUTH_ACTIVE=true
- Enable basic authN8N_BASIC_AUTH_USER=admin
- Admin usernameN8N_BASIC_AUTH_PASSWORD=secure_password
- Admin password
Complete docker-compose.yml Example
version: '3.8'
services:
postgres:
image: postgres:15
restart: always
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=n8n_password
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=n8n_password
- N8N_HOST=yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://yourdomain.com/
- GENERIC_TIMEZONE=America/New_York
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
volumes:
postgres_data:
n8n_data:
Users and authentication
Choose and set up user authentication for your n8n instance.
Authentication Methods
- Basic email/password authentication
- LDAP integration
- SAML SSO
- OAuth providers
Scaling
Manage data, modes, and processes to keep n8n running smoothly at scale.
Scaling Considerations
- Queue mode for workflow execution
- Database optimization
- Load balancing strategies
- Resource monitoring
Securing n8n
Secure your n8n instance by setting up SSL, SSO, or 2FA or blocking or opting out of some data collection or features.
SSL/TLS Setup with Caddy (Easiest)
Create a Caddyfile
:
n8n.yourdomain.com {
reverse_proxy localhost:5678
}
Run Caddy: docker run -d -p 80:80 -p 443:443 -v $PWD/Caddyfile:/etc/caddy/Caddyfile caddy:latest
Caddy automatically handles SSL certificates via Let's Encrypt!
SSL/TLS Setup with Nginx
1. Install Certbot: apt install certbot python3-certbot-nginx
2. Get SSL certificate: certbot --nginx -d n8n.yourdomain.com
3. Configure Nginx (/etc/nginx/sites-available/n8n
):
server {
listen 80;
server_name n8n.yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name n8n.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;
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;
}
}
Security Features
- SSL/TLS encryption: Always use HTTPS in production
- Two-factor authentication (2FA): Enable in user settings
- Single Sign-On (SSO): Available in Enterprise edition
- Basic Authentication: Use environment variables to set credentials
- Firewall Rules: Only expose necessary ports (80, 443)
- Regular Updates: Keep n8n updated for security patches
Firewall Configuration (UFW)
# Allow SSH (be careful not to lock yourself out!)
ufw allow 22
# Allow HTTP and HTTPS
ufw allow 80
ufw allow 443
# Enable firewall
ufw enable
# Check status
ufw status
Starter kits
New to n8n or AI? Try our Self-hosted AI Starter Kit. Curated by n8n, it combines the self-hosted n8n platform with compatible AI products and components to get you started building self-hosted AI workflows.
AI Starter Kit Features
- Pre-configured AI workflows
- Compatible AI tools integration
- Step-by-step setup guides
- Community templates
Self-hosting knowledge prerequisites
Self-hosting n8n requires technical knowledge, including:
- Setting up and configuring servers and containers
- Managing application resources and scaling
- Securing servers and applications
- Configuring n8n
Important: n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends n8n Cloud.
Troubleshooting Common Issues
n8n Won't Start
Check logs:
# Docker
docker logs n8n
# Docker Compose
docker-compose logs n8n
Common fixes:
- Ensure port 5678 is not already in use
- Check file permissions for volumes
- Verify environment variables are correct
Webhooks Not Working
Check:
- WEBHOOK_URL is set correctly
- Firewall allows incoming traffic
- SSL is properly configured if using HTTPS
- Domain DNS is pointing to your server
Database Connection Errors
PostgreSQL troubleshooting:
- Verify database credentials in environment variables
- Ensure PostgreSQL container is running:
docker ps
- Check network connectivity between containers
- Test connection:
docker exec -it postgres psql -U n8n -d n8n
Performance Issues
Optimize for production:
- Use PostgreSQL instead of SQLite
- Enable queue mode for workflow execution
- Increase server resources (CPU, RAM)
- Monitor with tools like Grafana or Prometheus
Getting Help
- Official Documentation: docs.n8n.io
- Community Forum: community.n8n.io
- GitHub Issues: github.com/n8n-io/n8n
- Discord: Join the n8n Discord server