Cloudflare Tunnel for Local Development
Expose your local development server to the web using Cloudflare Tunnel
Quick Setup
Install cloudflared
Download and install the Cloudflare Tunnel client (cloudflared) for your operating systemRun a quick tunnel (no setup required)
Executecloudflared tunnel --url http://localhost:8787to instantly expose your local Worker (typically running on port 8787)Access via free domain
Cloudflare automatically generates a random subdomain likehttps://wise-juvenile-pink-recovered.trycloudflare.com
Using Your Own Domain (Optional)
If you want a custom domain instead of the random subdomain:
Authenticate - Run
cloudflared tunnel loginto authorize with your Cloudflare accountCreate named tunnel - Execute
cloudflared tunnel create mytunnelto generate a persistent tunnel with UUIDConfigure routing - Create
~/.cloudflared/config.ymlspecifying your tunnel ID, credentials file, and hostname mapping to localhost:port~/.cloudflared/config.ymlNote
On Windows, this file is located at
C:\Users\<USERNAME>\.cloudflared\config.yml.Set DNS record - Run
cloudflared tunnel route dns mytunnel dev.yourdomain.comto create the DNS entryRun tunnel - Execute
cloudflared tunnel run mytunnelto start the tunnel
Does Cloudflare Provide a Domain?
Yes - When you run the quick tunnel command without authentication, Cloudflare automatically generates a free trycloudflare.com subdomain for you. However, this is a random subdomain that changes each time.
If you want a permanent custom domain (like dev.yourdomain.com), you need to own a domain and use Cloudflare’s nameservers.