Expose n8n (or any local app) to the Web with a $1 Domain + Cloudflare Tunnel

curve arrowExpose n8n online with a $1 domain + Cloudflare Tunnel

Watch Video

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

  1. Go to Cloudflare Dashboard → Add a Site → enter your domain (e.g., yourdomain.online).
  2. Choose the Free plan.
  3. Cloudflare scans DNS records → accept defaults.
  4. Cloudflare shows two nameservers (e.g., amy.ns.cloudflare.com, bob.ns.cloudflare.com).
  5. At your registrar → set your domain’s nameservers to Cloudflare’s.
  6. Wait ~10–30 minutes (sometimes a few hours).

Quick check:

bash
nslookup -type=ns yourdomain.online 1.1.1.1

It should return Cloudflare nameservers.

3) Install cloudflared

Windows (Winget):

bash
winget install Cloudflare.cloudflared

macOS (Homebrew):

bash
brew install cloudflare/cloudflare/cloudflared

Linux (Debian/Ubuntu):

bash
sudo apt-get install cloudflared

4) Create a Tunnel

Log in to Cloudflare (browser will open):

bash
cloudflared login

Create a tunnel (replace my-tunnel with a name you like):

bash
cloudflared tunnel create my-tunnel

Note the tunnel UUID. A credentials JSON is saved at:

bash
C:\Users\<YOU>\.cloudflared\<UUID>.json

5) Route a Subdomain

Pick a subdomain (e.g., n8n.yourdomain.online) and route DNS to the tunnel:

bash
cloudflared tunnel route dns my-tunnel n8n.yourdomain.online

6) Cloudflared Config

Create file:

bash
C:\Users\<YOU>\.cloudflared\config.yml

Put this content (adjust placeholders):

yaml
tunnel: <YOUR_TUNNEL_UUID>
credentials-file: C:\Users\<YOU>\.cloudflared\<YOUR_TUNNEL_UUID>.json
ingress:
- hostname: n8n.yourdomain.online
service: http://localhost:5678
- service: http_status:404
  • <YOUR_TUNNEL_UUID> → UUID from step 4
  • <YOU> → your Windows username
  • 5678 → 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:

yaml
services:
n8n:
image: n8nio/n8n
container_name: n8n
restart: unless-stopped
ports:
- "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

bat
@echo off
set "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 >nul
echo [START] Launching n8n container...
pushd "%PROJECT_DIR%"
docker compose up -d
popd
echo [OK] n8n should now be reachable at: %HOST_URL%
pause

stop-all.bat

bat
@echo off
set "PROJECT_DIR=%USERPROFILE%\n8n"
echo [STOP] Stopping n8n container...
pushd "%PROJECT_DIR%"
docker compose down
popd
echo [STOP] Stopping Cloudflare Tunnel...
taskkill /IM cloudflared.exe /F >nul 2>&1
echo [CLOSED] External access is now blocked.
pause

9) Start Everything

  1. Double-click start-all.bat.
  2. Cloudflared window should show Connected.
  3. Docker starts the n8n container.
  4. Open: https://n8n.yourdomain.online

10) Stop Everything

  1. Double-click stop-all.bat.
  2. Tunnel is closed.
  3. n8n container is stopped.
  4. External access is blocked.

What to Replace

  • yourdomain.online → your own domain
  • n8n.yourdomain.online → your chosen subdomain
  • my-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. 🎯