Skip to content
AutomationCampus

n8n

Host n8n online for $1 with a domain and Cloudflare Tunnel

Run n8n locally with Docker and expose it over HTTPS with a $1 domain and a free Cloudflare Tunnel. Step by step, with configs and scripts.

Reda Marzouk 10 min read

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

  1. Go to the Cloudflare dashboard → Add a Site → enter your domain.
  2. Choose the Free plan.
  3. Cloudflare scans your DNS records; accept the 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, which should return the Cloudflare nameservers:

terminal
nslookup -type=ns yourdomain.online 1.1.1.1

3. Install cloudflared

Windows (winget):

powershell
winget install Cloudflare.cloudflared

macOS (Homebrew):

terminal
brew install cloudflare/cloudflare/cloudflared

Linux (Debian/Ubuntu):

terminal
sudo apt-get install cloudflared

4. Create a tunnel

Log in to Cloudflare (a browser window will open):

terminal
cloudflared login

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

terminal
cloudflared tunnel create my-tunnel

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

path
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:

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

6. Configure cloudflared

Create this file:

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

Put this content in it, adjusting the placeholders:

config.yml
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> → the UUID from step 4
  • <YOU> → your Windows username
  • 5678 → 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:

docker-compose.yml
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

start-all.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

stop-all.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. The 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. The tunnel is closed.
  3. The 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> → 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.

Want a production n8n setup instead?

Hardened self-hosting, backups, monitoring and workflows with error handling: fixed-price n8n packages from $250.