Overview
This guide shows how to run n8n locally but make it accessible anywhere in the world using:
- A cheap domain (for example from Namecheap, about $1 for the first year)
- A free Cloudflare account (for DNS and the tunnel)
- Cloudflare Tunnel (
cloudflared) - Docker Desktop (to run n8n)
1. Buy a domain
Buy a domain (for example yourdomain.online) from a registrar like Namecheap or Cloudflare Registrar.
2. Add the domain to Cloudflare
- Go to the Cloudflare dashboard → Add a Site → enter your domain.
- Choose the Free plan.
- Cloudflare scans your DNS records; accept the 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, which should return the Cloudflare nameservers:
nslookup -type=ns yourdomain.online 1.1.1.1
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 (a browser window 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 file is saved at:
C:\Users\<YOU>\.cloudflared\<UUID>.json
5. Route a subdomain
Pick a subdomain (e.g. n8n.yourdomain.online) and route its DNS to the tunnel:
cloudflared tunnel route dns my-tunnel n8n.yourdomain.online
6. Configure cloudflared
Create this file:
C:\Users\<YOU>\.cloudflared\config.yml
Put this content in it, adjusting the 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>→ the UUID from step 4<YOU>→ your Windows username5678→ your app’s local port (n8n’s default)
7. Run 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. - The cloudflared window should show Connected.
- Docker starts the n8n container.
- Open
https://n8n.yourdomain.online.
10. Stop everything
- Double-click
stop-all.bat. - The tunnel is closed.
- The 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>→ the tunnel UUID<YOU>→ your local username- Passwords & secrets → choose strong values
Done
You are now running n8n locally with a secure public HTTPS URL through Cloudflare Tunnel, all for the price of a $1 domain.