GuidesSecurity

Cloudflare Tunnel: what it is, if it's free, and how to set it up

What Cloudflare Tunnel and cloudflared do, what is free, quick tunnels and their limits, setup from the dashboard or config.yml, and Access in front.

December 4, 2026The Everpod team
The short answer

Cloudflare Tunnel publishes a service on your server under a hostname on Cloudflare without opening any inbound port. A small daemon, cloudflared, dials out to Cloudflare and Cloudflare sends visitors back down that connection. It is free on every Cloudflare plan. For a throwaway URL with no account, run cloudflared tunnel --url http://localhost:3000 and you get a random trycloudflare.com address. For a lasting one on your own domain, create a tunnel under Networking > Tunnels in the dashboard and install it on the server with the token it gives you. Either way the address is open to anyone on the internet until you put a Cloudflare Access policy in front of it, which is free for up to 50 users.

How it works

cloudflared runs on the machine that has the service, opens outbound connections to Cloudflare on port 7844 (QUIC over UDP, falling back to HTTP/2 over TCP), and keeps them open. Cloudflare’s Tunnel overview says each tunnel holds four long-lived connections to two Cloudflare data centers. When someone opens your hostname, the request lands at Cloudflare and travels down one of those connections; cloudflared then makes an ordinary local request to the service you named, such as http://localhost:3000.

Two things follow. The server needs no public port and no inbound firewall rule: Cloudflare’s own advice is to block all ingress. And the service itself can stay bound to 127.0.0.1, since cloudflared reaches it locally. A dev server, an agent’s web interface or a webhook receiver never needs to listen on 0.0.0.0 to be published this way, and it should not. The tunnel carries only what the hostname points at, but what it carries is public until an Access policy stands in front of it.

Is it free?

Yes. The overview says Tunnel is “available on all plans”, the free one included. Access, the login wall you put in front, comes with Cloudflare’s Zero Trust plans: as of December 2026 the Free plan is $0 for up to 50 users, and the Pay-as-you-go plan is $7 per user per month. What a named tunnel does need is a domain added to Cloudflare, with its DNS served there. A quick tunnel needs neither an account nor a domain.

How it stacks up against a private network such as Tailscale, where nothing is public at all, is a separate decision, covered in Tailscale vs Cloudflare Tunnel.

Installing cloudflared

The current release is 2026.12.0, published December 3, 2026; the project supports versions up to a year old. On Debian or Ubuntu, Cloudflare’s install steps add its package repository:

sudo mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
sudo apt-get update && sudo apt-get install cloudflared
Copied

On a Mac it is brew install cloudflared. Check with cloudflared --version. Cloudflare has also started documenting a general command-line tool, cf, with equivalents such as cf tunnels quick-start; it runs cloudflared underneath, and the commands below use cloudflared directly.

Quick tunnels: a public URL in one command

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

It prints a random https://….trycloudflare.com address and serves your local port there until you press Ctrl+C. Run without --url, cloudflared answers “If you are trying to run a Quick Tunnel then you need to explicitly pass the --url flag.” What the quick tunnel page sets out, as of December 2026:

PropertyQuick tunnel
Who can open it
Anyone with the URL, unless you add --allowed-mail
Address
Random, new every time you start it
Lifetime
Until the process stops
Concurrency
200 requests in flight; more get a 429
Server-Sent Events
Not supported
Uptime guarantee
None; meant for testing and development

“Anyone with the URL” deserves a moment’s thought before you point a quick tunnel at a coding agent’s web interface. Whatever that page lets you do, including running commands on the server, the URL lets its holder do, and a URL travels: chat history, browser sync, a screenshot. The random name is not a password. Quick tunnels also do not carry Server-Sent Events, so an interface that streams its output that way may load and then never update.

Since cloudflared 2026.9.2 a quick tunnel can ask for an email address first. Visitors enter their address, receive a one-time PIN, and get in only if the address is on your list; they need no Cloudflare account:

cloudflared tunnel --url http://localhost:3000 --allowed-mail you@example.com
Copied

Repeat the flag or comma-separate addresses, and quote a whole-domain wildcard such as '*@example.com' so the shell leaves it alone. The check needs a browser, so scripts and webhook senders cannot pass it, and the list is fixed for the life of the process: changing it means a new tunnel with a new address. If a dev server answers the tunnel with a “Blocked request” page, that is the dev server’s own host check, and opening a localhost app on a remote server has the fix for Vite and Next.js.

A named tunnel from the dashboard

For a stable hostname on your own domain, Cloudflare recommends a remotely managed tunnel: its routes live in the dashboard and the server only needs a token. That suits a headless server, since nothing there needs a browser. The steps below follow Cloudflare’s getting-started page.

Step 4 is the one that opens the hostname. The moment you add the route, Cloudflare’s page says it plainly: “Anyone on the Internet can now access the application at the specified hostname.” Cloudflare recommends creating the Access application before the route, so the hostname is never open; the Access section below does that, and its steps work the same before the route exists.

  1. In the Cloudflare dashboard, go to Networking > Tunnels and select Create Tunnel; give it a name.
  2. Under Setup Environment, pick the server’s OS and architecture. The Install and Run step shows a command ending in a long token beginning eyJ.
  3. Install it on the server (below), wait for the tunnel to show Healthy, and select Continue.
  4. Under Routes, select Add route > Published application, enter a subdomain, pick the domain, set Service URL to the local address, for example http://localhost:3000, and select Add route. On a domain whose DNS is on Cloudflare the DNS record is created for you.

The dashboard’s Linux command is sudo cloudflared service install <TUNNEL_TOKEN>. The token is a credential: Cloudflare’s token page says “Anyone with the token can run the tunnel”, so a stolen token lets someone else connect to it and receive your hostname’s traffic. Pasted onto the command line it lands in your shell history, so read it into a variable instead. And don’t pass it through sudo: sudo writes every command it runs, arguments included, to the system log (on Ubuntu /var/log/auth.log, which members of the adm group can read without sudo), so the token would stay there. Open a root shell first:

sudo -i
Copied

Then, in that shell, paste the token when the prompt appears; nothing is echoed. The install still receives it as an argument, visible in the process list for the moment it runs:

printf 'Tunnel token: '
read -rs CF_TUNNEL_TOKEN; echo
cloudflared service install "$CF_TUNNEL_TOKEN"
unset CF_TUNNEL_TOKEN
exit
Copied

If the token leaks, open the tunnel’s Overview tab, select Rotate token in the Tunnel token card and tick Also disconnect existing replicas. The tunnel stops carrying traffic until you reinstall with the new token:

sudo cloudflared service uninstall
Copied

then the install block above again. Without the tick, connections already open keep working until they restart, and only new ones are refused.

A locally managed tunnel with config.yml

The older way keeps the routes in a file on the server, which suits configuration kept in git or several hostnames on one machine; Cloudflare recommends the dashboard way for most uses. It needs one browser sign-in to fetch an account certificate. On a server with no browser, login prints “Please open the following URL and log in with your Cloudflare account” and a URL: open it on any computer, pick the domain, and leave the command running until it downloads the certificate.

cloudflared tunnel login
cloudflared tunnel create my-server
Copied

login saves cert.pem to ~/.cloudflared; create prints the tunnel’s UUID and writes a credentials file, ~/.cloudflared/<UUID>.json, which holds the tunnel’s secret. Then write ~/.cloudflared/config.yml. Ingress rules are matched top to bottom, and the configuration reference requires a catch-all as the last rule:

tunnel: <UUID>
credentials-file: /home/you/.cloudflared/<UUID>.json

ingress:
  - hostname: agent.example.com
    service: http://localhost:3000
  - hostname: hooks.example.com
    service: http://localhost:8787
  - service: http_status:404
Copied

Check the file, create a DNS record for each hostname (a CNAME to <UUID>.cfargotunnel.com), and run it in the foreground to test:

cloudflared tunnel ingress validate
cloudflared tunnel ingress rule https://agent.example.com
cloudflared tunnel route dns my-server agent.example.com
cloudflared tunnel route dns my-server hooks.example.com
cloudflared tunnel run my-server
Copied

ingress rule tells you which rule a URL would hit. If a hostname already has a DNS record, Cloudflare reports “An A, AAAA, or CNAME record with that host already exists”; pick another name or delete the old record.

Running it as a service

cloudflared service install writes a systemd unit, /etc/systemd/system/cloudflared.service, enables it so it survives reboots, and starts it. From cloudflared’s source and its release notes, three things are worth knowing:

For a locally managed tunnel, the install is:

sudo cloudflared --config /home/you/.cloudflared/config.yml service install
systemctl status cloudflared
Copied

Only one cloudflared service fits on a machine; a second install fails with “cloudflared service is already installed”. Add the new hostname as another route or ingress rule on the existing tunnel instead.

Putting Cloudflare Access in front

An Access application makes Cloudflare ask who the visitor is before a request reaches the tunnel. Access is deny by default: only people matched by an Allow policy get through. For a hostname only you should open:

  1. In Zero Trust, go to Integrations > Identity providers and add One-time PIN, or connect Google, GitHub or another provider. Cloudflare no longer adds the PIN method automatically to new accounts. A PIN expires ten minutes after it is sent, and is sent only to addresses a policy allows.
  2. Go to Access controls > Applications, select Create new application, then Self-hosted and private and Add public hostname, and enter the tunnel’s hostname.
  3. Add a policy with the action Allow and an Include rule of Emails with your address (or Emails ending in for a team’s domain). Choose the identity providers, then Create.
  4. In Networking > Tunnels, open the tunnel’s Routes tab, choose Edit route on the published application, and under Additional application settings turn on Protect with Access, so that cloudflared itself rejects any request without a valid Access token, a second check in case the Access application is ever removed or the hostname changes.

In a config file, that last step is an access block under the rule’s originRequest, using your team name and the application’s audience tag from its settings:

  - hostname: agent.example.com
    service: http://localhost:3000
    originRequest:
      access:
        required: true
        teamName: your-team
        audTag:
          - <application-audience-tag>
Copied

Two policy choices undo the protection. Bypass “does not enforce any Access security controls and requests are not logged”, in the words of Cloudflare’s policy docs, and an Allow policy that includes Everyone lets anyone in. Keep the service’s own login too, where it has one: Access decides who reaches the page, not what they can do on it.

A webhook receiver is the exception. GitHub, Stripe or a chat platform cannot sign in through Access, so the hostname for webhooks stays open, and the receiver checks the signature each sender puts on its requests and drops anything unsigned. Give webhooks a hostname of their own, as in the config above, so that the agent’s interface keeps its Access application and only the receiver is public. An agent gateway that can act on your machine never belongs on an open hostname; the OpenClaw gateway guide explains why.

When it will not connect

The errors people meet most, with the fixes from Cloudflare’s troubleshooting page:

What you seeWhat it means
Error 1033 in the browser
No connector is serving the hostname. Check the tunnel’s status: Inactive (never ran), Down (stopped; restart the service), Degraded (some connections failed; check outbound 7844). If it is Healthy, the CNAME points at a different tunnel.
502, “Unable to reach the origin service”
The tunnel works but the local service does not answer. In the logs, connect: connection refused means nothing listens on that port; malformed HTTP response means http:// and https:// are swapped in the service URL.
timeout: handshake did not complete in time on a QUIC dial
Outbound UDP 7844 is blocked. Allow it, or run cloudflared with --protocol http2 to use TCP 7844 instead.
ERR_TOO_MANY_REDIRECTS
The app redirects HTTP to HTTPS while the route’s Service URL is http://. Cloudflare’s page on HTTPS origins covers choosing the Service URL and origin settings that end the loop.
x509: certificate is valid for example.com, not localhost
An HTTPS service whose certificate names another host. Set Origin Server Name to that name rather than turning off verification.

If the server’s visitors are only ever you and your own devices, a public hostname is more than the job needs. Tailscale Serve gives the same web interface an HTTPS address that only your own devices can open, with nothing published at all.

Run Claude Code, Codex, OpenCode, Pi, Hermes or OpenClaw on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.