· development

Use Cloudflare to share localhost for free

Set up a tunnel locally. Follow this step-by-step guide to get your first tunnel up and running using the CLI.

From time to time you’ll want to share your locally running app with some folks before it’s ready to ship.

  • Free to use
  • HTTPS support
  • Won’t expose your IP

Prerequisites

Before you start add a website to CloudflareExternal link icon.

Download and install cloudflared

When on a Mac running the following command

brew install cloudflare/cloudflare/cloudflared

When on Windows download the executable hereExternal link icon64bit.

Quick setup with random URL

cloudflared tunnel --url http://localhost:3000

Check the terminal for the public URL. This be an URL like: https://voluntary-canal-amend-collins.trycloudflare.com

Use custom domain name

In some cases you want the tunnel to have a stable URL. Therefore Cloudflare offers the option to couple your domain name on which the funnel gets registered.

Authenticate with Cloudflare

Now we can create our first tunnel by running the following command.

cloudflared tunnel login

This will open a browser window and prompt you to log in to your Cloudflare account. After logging in to your account, select your hostname.

Create a tunnel and give it a name

cloudflared tunnel create mycoolapp

Confirm that the tunnel has been successfully created by running:

cloudflared tunnel list

Start routing traffic

Now assign a CNAME record that points traffic to your tunnel subdomain.

cloudflared tunnel route dns mycoolapp demo.yourdomain.me

Run the tunnel

Run the tunnel to proxy incoming traffic from the tunnel to any number of services running locally on your origin.

cloudflared tunnel --url <http://localhost:3000> run mycoolapp

Check the tunnel

cloudflared tunnel info
To Blog