keepcalculator

06 Numbers and Powers

Cloudflare Quick Tunnel: Share Localhost Publicly

Card No. 06·17824 · Updated · Standard formula, shown below

A Cloudflare Quick Tunnel gives a local web app a temporary public HTTPS address, so someone outside your network can open it without router port forwarding. You run Cloudflare’s cloudflared command against the app’s local port; the tunnel URL works only while the command and local app are running.

What You’ll Need

  • A web server or app running on your computer, with its local address and port—for example, http://localhost:3000.
  • cloudflared installed, or permission to download and run it for your operating system.
  • An internet connection. A Cloudflare account and domain are not required for a Quick Tunnel.
  • Permission to expose the app. Anyone with the generated URL may be able to reach it, so do not use this for private or sensitive services.

Step-by-Step

  1. Start your local app. Run it using its usual command or development tool. Confirm that it works on your own computer by opening its local URL, such as http://localhost:3000. Note the port number. If the app only listens on a particular network interface, check its documentation; cloudflared must be able to reach it locally.
  2. Install or locate cloudflared. Use Cloudflare’s official installation instructions for your operating system. On Windows, you can install the appropriate package or download the executable; on macOS or Linux, use the documented package or binary for your system. If you already installed it, open a terminal and run cloudflared --version to check that the command is available. Follow the installation guide if the shell says the command cannot be found.
  3. Open a second terminal. Leave the app running in its original window, then open another terminal or command prompt for the tunnel. This keeps the two processes separate and makes it easier to see whether either one has stopped.
  4. Start the Quick Tunnel. Replace 3000 with the port your app uses, and run:
    cloudflared tunnel --url http://localhost:3000
    If your app uses another local hostname or port, use that actual address instead. For a local HTTPS service, specify its HTTPS URL, for example https://localhost:8443; certificate or origin configuration may need extra attention. Do not add a trailing path such as /login to the origin unless your setup specifically requires it.
  5. Wait for the public URL. Keep the terminal open. When the tunnel connects, the output displays a URL on the trycloudflare.com domain. Copy that complete HTTPS URL and open it in a browser. The first connection may take a short while. If the command reports an error instead, use the troubleshooting section below.
  6. Test from outside your local setup. Open the URL in a private browser window or on a phone using mobile data, not the same Wi-Fi connection. Check the pages and functions you intend to share. This helps catch cases where the homepage loads but an app feature still points to a local-only address.
  7. Keep the tunnel running while it is needed. Do not close the terminal or stop the local app. If either process exits, the public address will stop serving your app. When you are finished, press Ctrl+C in the tunnel terminal, then stop the app. The Quick Tunnel is temporary; a later run may generate a different URL.

Common Mistakes

  • Using the wrong port: The number after the colon in the app’s local URL must match the port in the tunnel command. A tunnel to port 3000 cannot serve an app listening on 8080.
  • Starting the tunnel before the app: The public connection can come up even when the local service is unavailable. Start the app first and verify its local page.
  • Closing the terminal: The tunnel is a running process, not a permanent hosting setup. Closing its window or sleeping the computer disconnects it.
  • Sharing sensitive content: Treat the generated URL as public. Do not expose admin panels, files, databases, or development tools containing secrets without appropriate access controls.
  • Expecting a fixed address: Quick Tunnel URLs are temporary and are not intended as a stable custom domain. Use a named tunnel and a domain configured in Cloudflare if you need a persistent address.

Tips

  • Copy the URL from the tunnel’s terminal output rather than guessing it. Keep the full https:// prefix.
  • For team testing, share the address through an appropriate channel and tell recipients that it may stop working when you end the session.
  • Watch both terminal windows for errors. App errors appear in the app’s terminal; tunnel connection and forwarding messages appear in the cloudflared terminal.
  • Some apps create absolute links or use a configured base URL. If the page loads but links, callbacks, or live updates fail, check the app’s host, proxy, and public-URL settings.

Troubleshooting

  • The command is not recognized: Confirm installation and try cloudflared --version. If the executable exists but the command is unavailable, run it from its installation folder or add that folder to your PATH as described in the operating system’s documentation.
  • The public page shows an error or cannot connect: Open the origin locally again and verify the port. Make sure the app is still running, then check that the URL in the command uses the right protocol, hostname, and port. Restart the tunnel after correcting it.
  • The tunnel does not connect: Check that the computer has internet access and that a firewall, proxy, or managed network is not blocking the connection. Try again on a permitted network; on a workplace or school network, ask its administrator about restrictions rather than bypassing them.
  • The page loads, but features fail: Look in the browser’s developer console and the app logs. Check for hard-coded references to localhost, blocked cross-origin requests, WebSocket configuration, or an application setting that rejects requests from the public hostname.
  • The link stopped working: Confirm both processes are still running. If the tunnel ended or you restarted it, copy the newly displayed URL and share that one instead.

Frequently Asked Questions

Do I need a Cloudflare account or domain?
No. Quick Tunnels are designed for temporary testing and provide a generated trycloudflare.com address without requiring you to configure your own domain.

Can I use this with any local app?
It works with services reachable over HTTP or HTTPS at a local address and port. Apps that need special network protocols, complex authentication, or additional callbacks may require configuration beyond starting a tunnel.

Does the URL stay the same?
Do not rely on it staying the same. Quick Tunnel URLs are temporary; restarting the command can give you a new address.

Can other people access my localhost through the link?
They can reach the service exposed by the tunnel while it is running. Share the URL only with intended recipients, and do not assume that an unguessable address is a substitute for authentication.

Is my computer acting as the server?
Yes. The app continues to run on your computer, and cloudflared creates an outbound connection that lets requests reach it. Your computer must remain on and connected for the service to work.

How do I get a permanent public address?
Set up a named Cloudflare Tunnel connected to a domain in your Cloudflare account. That is a different setup from a Quick Tunnel and is better suited to a stable hostname.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →