Self-Host n8n: Workflow Automation in 15 Minutes
Why Self-Host n8n?
n8n is the most powerful open-source workflow automation platform available today. Unlike Zapier or Make, n8n gives you unlimited workflows, self-hosted data privacy, and 400+ integrations without per-task pricing. Self-hosting means your automation data never leaves your infrastructure — critical for businesses handling sensitive data or those wanting to avoid vendor lock-in.
Whether you're automating CI/CD pipelines, syncing CRM data, building AI agent workflows, or orchestrating multi-step business processes, n8n handles it all with a visual drag-and-drop interface that developers actually enjoy.
What You'll Build
By the end of this guide, you'll have:
- n8n running in Docker with persistent data
- A secure, production-ready setup with basic auth
- Your first workflow triggered and running
- Webhook endpoints ready for external integrations
Prerequisites
- VPS: 2 vCPU, 4GB RAM, 20GB SSD (minimum)
- OS: Ubuntu 22.04/24.04 LTS or Debian 12
- Docker & Docker Compose: Installed and running
- Domain: Pointed to your VPS (optional but recommended)
- SSL: Let's Encrypt or Cloudflare (optional but recommended)
Step 1: Create the Docker Compose File
Create a dedicated directory for n8n:
mkdir -p ~/n8n && cd ~/n8n
Create docker-compose.yml:
version: "3.8"
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
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=n8n.yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://n8n.yourdomain.com/
- GENERIC_TIMEZONE=UTC
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Replace these values:
N8N_BASIC_AUTH_USER/PASSWORD— Your login credentialsN8N_HOST— Your domain or VPS IPN8N_PROTOCOL— http if no SSL, https if using SSLWEBHOOK_URL— Public URL for webhook triggers
Step 2: Launch n8n
docker compose up -d
Pulls the latest image and starts n8n in detached mode. First startup takes 30-60 seconds.
Step 3: Verify the Deployment
Check container status:
docker compose ps
View logs:
docker compose logs -f
You should see: Editor is now accessible via: https://n8n.yourdomain.com:5678
Step 4: Access the Web UI
Navigate to http://YOUR_VPS_IP:5678 (or your domain if configured).
Login with the credentials from your docker-compose.yml.
Step 5: Create Your First Workflow
- Click "Add Workflow"
- Click "Add first step"
- Search for "Schedule Trigger" — set to run every minute
- Add a second node: "HTTP Request" — make a test API call
- Click "Test Workflow" to execute manually
- Toggle "Active" to enable scheduled execution
Congratulations — you've built a self-hosted automation engine.
Production Hardening (Do This Next)
| Security Measure | Implementation |
|---|---|
| Reverse Proxy | Traefik or Nginx with SSL termination |
| Firewall | UFW — allow only 80/443, block 5678 public |
| Backups | Volume snapshots or docker cp exports |
| Updates | Watchtower or manual docker compose pull |
| Secrets | Use .env files, never commit credentials |
Sample Production docker-compose.yml
For Traefik users, here's an enhanced configuration:
version: "3.8"
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: always
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=${N8N_USER}
- N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
- N8N_HOST=n8n.yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://n8n.yourdomain.com/
- GENERIC_TIMEZONE=UTC
- EXECUTIONS_MODE=regular
- EXECUTIONS_TIMEOUT=3600
volumes:
- n8n_data:/home/node/.n8n
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.n8n.rule=Host(`n8n.yourdomain.com`)"
- "traefik.http.routers.n8n.tls.certresolver=letsencrypt"
- "traefik.http.services.n8n.loadbalancer.server.port=5678"
volumes:
n8n_data:
networks:
traefik:
external: true
Verification Checklist
- ☐ Container running:
docker compose psshows "Up" - ☐ Web UI accessible at your domain/IP
- ☐ Basic auth login works
- ☐ Test workflow executes successfully
- ☐ Webhook URL responds to external requests
- ☐ Data persists after container restart
Next Steps
- AI Workflows: Connect n8n to OpenAI, Ollama, or LiteLLM for AI agent automation
- Database Triggers: Automate actions on PostgreSQL row changes
- CI/CD Integration: Trigger deployments from GitHub webhooks
- Monitoring: Pair with Uptime Kuma for workflow failure alerts
- Backup Automation: Schedule daily exports to S3/MinIO
Related Guides
- Self-Host Portainer: Docker Management
- Self-Host Traefik: Modern Reverse Proxy
- Self-Host Uptime Kuma: Monitor Everything
- Self-Host PostgreSQL: Production Database
Self-hosting n8n gives you unlimited workflow automation without per-task pricing or vendor lock-in. In 15 minutes, you've built the foundation for automating your entire infrastructure.
Questions or issues? Drop a comment below or reach out on our Discord.