Overview
This guide shows how to run n8n locally but make it accessible anywhere in the world using:
- A cheap domain (e.g., from Namecheap, ≈$1 for the first year)
- A free Cloudflare account (for DNS + Tunnel)
- Cloudflare Tunnel (
cloudflared
) - Docker Desktop (to run n8n)
1) Buy a Domain
Buy a domain (example: yourdomain.online
) from a registrar like Namecheap or Cloudflare Registrar.
2) Add Domain to Cloudflare
- Go to Cloudflare Dashboard → Add a Site → enter your domain (e.g.,
yourdomain.online
). - Choose the Free plan.
- Cloudflare scans DNS records → accept defaults.
- Cloudflare shows two nameservers (e.g.,
amy.ns.cloudflare.com
,bob.ns.cloudflare.com
). - At your registrar → set your domain’s nameservers to Cloudflare’s.
- Wait ~10–30 minutes (sometimes a few hours).
Quick check:
nslookup -type=ns yourdomain.online 1.1.1.1
It should return Cloudflare nameservers.
3) Install cloudflared
Windows (Winget):
winget install Cloudflare.cloudflared
macOS (Homebrew):
brew install cloudflare/cloudflare/cloudflared
Linux (Debian/Ubuntu):
sudo apt-get install cloudflared
4) Create a Tunnel
Log in to Cloudflare (browser will open):
cloudflared login
Create a tunnel (replace my-tunnel
with a name you like):
cloudflared tunnel create my-tunnel
Note the tunnel UUID. A credentials JSON is saved at:
C:\Users\<YOU>\.cloudflared\<UUID>.json
5) Route a Subdomain
Pick a subdomain (e.g., n8n.yourdomain.online
) and route DNS to the tunnel:
cloudflared tunnel route dns my-tunnel n8n.yourdomain.online
6) Cloudflared Config
Create file:
C:\Users\<YOU>\.cloudflared\config.yml
Put this content (adjust placeholders):
tunnel: <YOUR_TUNNEL_UUID>credentials-file: C:\Users\<YOU>\.cloudflared\<YOUR_TUNNEL_UUID>.jsoningress:- hostname: n8n.yourdomain.onlineservice: http://localhost:5678- service: http_status:404
<YOUR_TUNNEL_UUID>
→ UUID from step 4<YOU>
→ your Windows username5678
→ your app’s local port (n8n default)
7) n8n with Docker Compose
Create a folder (e.g., C:\\Users\\<YOU>\\n8n
). Inside it, create docker-compose.yml
:
services:n8n:image: n8nio/n8ncontainer_name: n8nrestart: unless-stoppedports:- "5678:5678"environment:GENERIC_TIMEZONE: "Europe/Paris"N8N_ENCRYPTION_KEY: "your-32-char-secret" # must stay stable!WEBHOOK_URL: "https://n8n.yourdomain.online"N8N_EDITOR_BASE_URL: "https://n8n.yourdomain.online"N8N_PROTOCOL: "https"N8N_HOST: "n8n.yourdomain.online"N8N_BASIC_AUTH_ACTIVE: "true"N8N_BASIC_AUTH_USER: "admin"N8N_BASIC_AUTH_PASSWORD: "supersecret"volumes:- ./n8n_data:/home/node/.n8n
8) Start/Stop Scripts (Windows)
Create two .bat files on your Desktop.
▶️ start-all.bat
@echo offset "PROJECT_DIR=%USERPROFILE%\n8n"set "TUNNEL_NAME=my-tunnel"set "HOST_URL=https://n8n.yourdomain.online"echo [START] Launching Cloudflare Tunnel...start "Cloudflared Tunnel" cmd /k cloudflared tunnel run "%TUNNEL_NAME%"timeout /t 2 /nobreak >nulecho [START] Launching n8n container...pushd "%PROJECT_DIR%"docker compose up -dpopdecho [OK] n8n should now be reachable at: %HOST_URL%pause
⏹ stop-all.bat
@echo offset "PROJECT_DIR=%USERPROFILE%\n8n"echo [STOP] Stopping n8n container...pushd "%PROJECT_DIR%"docker compose downpopdecho [STOP] Stopping Cloudflare Tunnel...taskkill /IM cloudflared.exe /F >nul 2>&1echo [CLOSED] External access is now blocked.pause
9) Start Everything
- Double-click
start-all.bat
. - Cloudflared window should show Connected.
- Docker starts the n8n container.
- Open:
https://n8n.yourdomain.online
10) Stop Everything
- Double-click
stop-all.bat
. - Tunnel is closed.
- n8n container is stopped.
- External access is blocked.
What to Replace
yourdomain.online
→ your own domainn8n.yourdomain.online
→ your chosen subdomainmy-tunnel
→ your tunnel name<YOUR_TUNNEL_UUID>
→ tunnel UUID string<YOU>
→ your local username- Passwords & secrets → choose strong values
Done
You’re running n8n locally with a secure public HTTPS URL via Cloudflare Tunnel — all for the price of a $1 domain. 🎯