Answer
How to Connect Local n8n with Outside Network
By default, n8n runs on
text
localhostWhy You Need External Access
n8n workflows often use webhooks — external services (Slack, GitHub, payment processors) send HTTP requests to your n8n instance. This requires a publicly accessible URL.
Option 1: ngrok (Easiest — Development)
bash# Install ngrok brew install ngrok # Mac # or download from ngrok.com # Authenticate ngrok config add-authtoken YOUR_TOKEN # Expose n8n (running on port 5678) ngrok http 5678
ngrok gives you a public URL like
text
https://abc123.ngrok.iobash# Set n8n webhook URL to ngrok URL export WEBHOOK_URL=https://abc123.ngrok.io n8n start
Limitation: Free ngrok URLs change every restart. Use ngrok's paid plan for a fixed URL.
Option 2: Cloudflare Tunnel (Free + Stable)
bash# Install cloudflared brew install cloudflare/cloudflare/cloudflared # Login to Cloudflare cloudflared tunnel login # Create a tunnel cloudflared tunnel create n8n-tunnel # Create config cat > ~/.cloudflared/config.yml << EOF tunnel: n8n-tunnel credentials-file: /Users/you/.cloudflared/n8n-tunnel.json ingress: - hostname: n8n.yourdomain.com service: http://localhost:5678 - service: http_status:404 EOF # Add DNS record (automatic) cloudflared tunnel route dns n8n-tunnel n8n.yourdomain.com # Run the tunnel cloudflared tunnel run n8n-tunnel
Now
text
https://n8n.yourdomain.comOption 3: VPS / Cloud Deployment
For production, run n8n on a server:
bash# Docker on VPS (DigitalOcean, Linode, Hetzner) docker run -d --name n8n -p 5678:5678 -e N8N_HOST=your-domain.com -e WEBHOOK_URL=https://your-domain.com -e N8N_PROTOCOL=https -v n8n_data:/home/node/.n8n n8nio/n8n
Add nginx + Let's Encrypt for HTTPS.
Option 4: n8n Cloud
Simplest — use n8n's hosted service at cloud.n8n.io. No infrastructure management needed.
Comparison
| Method | Cost | Setup | Stability | Best For |
|---|---|---|---|---|
| ngrok free | Free | Easy | Unstable URL | Quick testing |
| ngrok paid | $8+/mo | Easy | Stable URL | Development |
| Cloudflare Tunnel | Free | Medium | Stable | Development + staging |
| VPS (self-hosted) | $5-20/mo | Hard | Production-grade | Production |
| n8n Cloud | $20+/mo | None | Production-grade | Easiest production |
Set Webhook URL in n8n
bash# Environment variable approach N8N_HOST=your-domain.com N8N_PORT=5678 N8N_PROTOCOL=https WEBHOOK_URL=https://your-domain.com n8n start
This is critical — n8n uses
text
WEBHOOK_URL