DEV Community

Cover image for Expose Local n8n with a Custom HTTPS Domain Using Cloudflare Tunnel
Muhammad Mohsin
Muhammad Mohsin

Posted on

Expose Local n8n with a Custom HTTPS Domain Using Cloudflare Tunnel

Running n8n locally is great — until you need webhooks.

Services like Stripe, GitHub, or PayPal require a public HTTPS URL, and tools like ngrok quickly become limiting due to random URLs and session resets.

There’s a cleaner solution.

Using Cloudflare Tunnel, you can expose your local n8n instance on a stable, secure custom subdomain like:

https://n8n.yourdomain.com
Enter fullscreen mode Exit fullscreen mode

No open ports. No firewall rules. No temporary URLs.

Why Cloudflare Tunnel?

  • Free HTTPS with a custom domain
  • Stable URLs (perfect for webhooks)
  • No port forwarding required
  • More reliable than ngrok for long-running workflows

Works on macOS, Windows, and Linux.

High-Level Setup

The setup is surprisingly simple:

  1. Install Cloudflare Tunnel (cloudflared)
  2. Authenticate with Cloudflare
  3. Create a tunnel
  4. Map your subdomain
  5. Point it to local n8n
  6. Set n8n webhook environment variables

That’s it.

Why This Matters for n8n Users

With this setup you can:

  • Test Stripe, PayPal, and webhook-based workflows locally
  • Share demos with clients using a real domain
  • Avoid restarting tunnels or updating webhook URLs
  • Keep your local machine secure

Full Step-by-Step Guide

This post is intentionally short.

I wrote a complete, production-ready guide covering:

  • macOS, Windows & Linux setup
  • Tunnel configuration
  • n8n environment variables
  • Security best practices

👉 Read the full guide here:
🔗 https://mosen.dev

If you’re building real automations with n8n, this setup will save you a lot of time.

Happy automating 🚀

Top comments (0)