Skip to content

Cloudflare Tunnel for Mere Mortals

A service on a machine in your house — a dashboard, an app, a page of your own — normally cannot be reached from outside: the router hides it behind one shared address, and opening a way in means opening a port to the whole internet, if your provider leaves you an address to open it on at all. Cloudflare Tunnel turns the connection around. A small program, cloudflared, runs beside your service and dials out to Cloudflare, holding the connection open. Visitors use an ordinary hostname; Cloudflare's edge receives them and sends their requests back down the connection your machine already made. No inbound port, no router changes, no public address of yours exposed — and it works behind CGNAT, where port forwarding cannot.

This guide explains the two shapes the tunnel takes — the account-less quick tunnel with its random trycloudflare.com name, an experiment bench that lives exactly as long as its command; and the named tunnel, a permanent object in a free Cloudflare account answering at a hostname in your own domain — and it is plain about the rule that comes with publishing anything: a tunnel makes a service public, and public means everyone, so only services you would defend as public belong behind one.

The lab behind this guide ran the real program: cloudflared 2026.10.5, the official static binary, on a small Linux sandbox, against a one-page demo service the lab served to itself on loopback. Against it the lab installed and read the help, validated a config file and interrogated its ingress rules offline — including the refusals for a missing catch-all, a scheme-less service and broken YAML — asked the file which rule would answer four different addresses, probed the edge's DNS, TCP and UDP reachability, started the login ceremony, and collected the exact error that guards every account-bound command until login completes.

What the lab could not do, it did not fake. The sandbox's network was refused by Cloudflare's quick-tunnel provisioning — a plain 403, confirmed with a second tool — so no tunnel ever served a public visitor for this guide, and the lab had no Cloudflare account or domain of its own, so login's second half, tunnel creation, DNS routing and a running named tunnel are taught from the documentation and labelled documented-only wherever they appear. criteria.md keeps the full ledger of what was run and what was only read.

What this guide covers

  • What Cloudflare Tunnel is — the turned-around connection, the two shapes, and the publishing rule stated before anything depends on it
  • The moving parts — cloudflared, the origin, the two credential files that are not interchangeable, the tunnel object, routes, and the edge
  • Installing cloudflared — one static binary, the version check, and where its state lives
  • Your first tunnel — the quick tunnel: a local service, one command, and the lab's two instructive refusals
  • Logging in and named tunnels — the browser ceremony behind cert.pem, and the error that stands guard until it completes
  • The config file and ingress rules — first match wins, the compulsory catch-all, and asking the file questions before anything runs
  • Routing DNS and running the tunnel — the CNAME that contains no address of yours, the service install, and asking the tunnel if it is ready
  • Protocols and connections — QUIC over UDP, HTTP/2 over TCP, port 7844, and the lab's three probes
  • Recipes — a ten-minute demo for a friend, a permanent home address, two services on one tunnel, publishing only a public corner, and the gated service
  • The neighbours — port forwards, SSH's -R, Tailscale and Funnel, the VPS and reverse proxy, and the other tunnel services
  • Limits — Cloudflare reads the traffic by design, the door is web-shaped, quick tunnels are a bench, and a tunnel authenticates nobody
  • Troubleshooting — organised by the stage where the run stops: provisioning, the config file, connecting, serving
  • Glossary — the terms, collected in one place

What it doesn't cover

Publishing services that are not yours to publish, or tunnelling around a network policy you are subject to — a tunnel is an outbound connection, and using one to defeat an employer's or a provider's rules is a decision about your conduct, not a feature of the tool. Cloudflare Access in depth, private-network routing with WARP, Spectrum and the enterprise tiers, and running tunnels at fleet scale are pointed at, not taught; this guide stays with one person, their own machines, and their own domain.

How to use this guide

Read chapter 1 for the model and the rule, and chapter 2 before installing anything — knowing which credential file does what turns chapter 5's guard error from a wall into a signpost. Chapter 4 is best read with its transcripts open: the failure it documents is the one readers most often mistake for their own typo. Chapters 5 to 7 assemble, in order, into the permanent setup. Chapter 6 is the chapter to keep: validate and ask the file is a habit that survives every edit you will ever make to a running tunnel. The lab's transcripts live in cloudflared-lab/transcripts/; its demo page is cloudflared-lab/site/, its config files — good and deliberately broken — are cloudflared-lab/config/, and its notes are examples/lab-notes.txt.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.