Cloudflare Tunnel: Expose Your Local App Without Opening a Port (2026)
You have an app running on a machine you own — a Laravel app on a VPS, a photo gallery on a Raspberry Pi, a dev server on your laptop. You want it reachable at app.yourdomain.com, over HTTPS, from anywhere. The traditional way means opening a port on your router, pointing a DNS record at an IP address that keeps changing, and babysitting a Let’s Encrypt certificate. A Cloudflare Tunnel skips all of that: you install a small daemon called cloudflared, it dials out to Cloudflare and holds the connection open, and Cloudflare forwards requests for your hostname down that connection to your machine. No inbound port is ever opened. This guide covers the 30-second throwaway version, the permanent version two ways (dashboard and CLI), a login in front of it, SSH through it, and the limits that catch people out. Verified 21 November 2026.
How a Cloudflare Tunnel works
Four things exist once you are set up:
- The tunnel. A persistent object in your Cloudflare account, identified by a UUID — the logical link between Cloudflare and your machine.
- The connector. A running
cloudflaredprocess that holds the tunnel open with four outbound connections to two different Cloudflare data centres, so one data centre or one connection failing does not take you offline. You can run more connectors on other machines — Cloudflare calls those replicas. - The routes. Ingress rules mapping each hostname to a local service — stored in Cloudflare, or in a YAML file on your machine.
- The DNS record. A proxied CNAME from your hostname to
<UUID>.cfargotunnel.com.
A request comes in at the Cloudflare location nearest the visitor, travels across Cloudflare’s network to a location your connector is attached to, and goes down the tunnel to your app on localhost. The response comes back the same way.
Two consequences matter. First, Cloudflare terminates the visitor’s TLS at the edge, so your app can speak plain HTTP on localhost and the visitor still gets HTTPS with a valid certificate. Second, Cloudflare sees the traffic in plaintext at the edge, exactly as it does for any site behind its proxy — if that bothers you for a particular app, a tunnel is the wrong tool for it.
Pick a management style before you start. A remotely managed tunnel keeps its configuration in Cloudflare: you create it in the dashboard, you get a token, and adding a hostname is a form. A locally managed tunnel keeps its configuration in ~/.cloudflared/config.yml. Cloudflare pushes you toward remotely managed, and for a home server or a single VPS that is the right call.
What you need before you start
- A Cloudflare account. The free one is enough — the tunnel is included on every plan.
- A domain whose nameservers point at Cloudflare. Publishing a hostname requires a domain on Cloudflare DNS.
- A machine that stays on, with outbound internet access.
cloudflaredconnects out on port7844(UDP for QUIC, TCP for the HTTP/2 fallback) — a very strict firewall may need that opened outbound. Nothing inbound. - Something to serve — the examples use a Node.js app on port 8000.
First, try a Quick Tunnel (30 seconds, no account)
Before you commit to a named tunnel, prove the idea works with a Quick Tunnel. Install cloudflared (below), start your app, and run:
cloudflared tunnel --url http://localhost:8000
You get a random trycloudflare.com URL that lives until you press Ctrl-C. No account, no domain, no DNS.
Quick Tunnels have real limits: the URL changes on every restart, they proxy one origin only, they cap at 200 in-flight requests, Server-Sent Events do not stream through them, and Cloudflare gives them no uptime guarantee. When you want a stable hostname, you want a named tunnel.
Install cloudflared
On Debian and Ubuntu, use Cloudflare’s apt 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
On macOS, brew install cloudflared. On Windows, download the installer from Cloudflare’s downloads page or the GitHub releases. There is also a Docker image, cloudflare/cloudflared.
Check with cloudflared --version — the current release is 2026.10.7 (30 October 2026).
Path A: set it up in the dashboard (recommended)
Start your app first. Then, in the Cloudflare dashboard, go to Networking, then Tunnels, and select Create Tunnel. Give it a name that describes the machine, like macmini-home or production-web — a tunnel usually outlives the app you made it for. Under Setup Environment, pick the operating system and architecture of your server, and the dashboard shows an install command under Install and Run:
sudo cloudflared service install eyJhIjoiNmZmNDJhZTIt...
That long eyJ... string is the tunnel token. Treat it like a password: anyone who has it can run a connector that joins your tunnel and receives your traffic.
Run the command on the machine. It installs cloudflared as a system service, stores the token, and starts it. Within a few seconds the dashboard says the tunnel is connected — select Continue. Your tunnel shows a status on the Tunnels page: Healthy (all four connections up), Degraded (serving, but at least one connection failed), Down (was connected, is not anymore), or Inactive (never connected). On Linux, check the service with systemctl status cloudflared and journalctl -u cloudflared -f.
Add a route
Select the tunnel, open the Routes tab, select Add route, then Published application. Under Hostname, type the subdomain (photos) and pick your domain from the dropdown. Under Service URL, enter where the app lives from the point of view of the machine running cloudflared: http://localhost:8000. Select Add route and Cloudflare creates the DNS record for you — a proxied CNAME to <UUID>.cfargotunnel.com. Open https://photos.yourdomain.com and your app answers.
One gotcha: if your app serves HTTPS or redirects HTTP to HTTPS, use https://localhost:443 as the Service URL and set Origin Server Name — otherwise you get ERR_TOO_MANY_REDIRECTS.
Running in Docker instead? The dashboard’s token works there too:
docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token <TUNNEL_TOKEN>
Path B: set it up from the CLI (a config file you own)
Same result, different tools, and you end up with a config file you own.
Authenticate
cloudflared tunnel login
This opens a browser. Log in to Cloudflare and pick the domain you will use. cloudflared saves an account certificate at ~/.cloudflared/cert.pem — that file lets cloudflared create tunnels and DNS records in your account, so it is as sensitive as the dashboard login.
Create the tunnel
cloudflared tunnel create macmini-home
Cloudflare registers the tunnel, prints its UUID, and writes a credentials file (something like ~/.cloudflared/58540a18-2a19-4329-822f-2c3e5f795270.json). That JSON is the local equivalent of the token, so keep it secret.
Write the config file
Create ~/.cloudflared/config.yml:
tunnel: 58540a18-2a19-4329-822f-2c3e5f795270
credentials-file: /home/you/.cloudflared/58540a18-2a19-4329-822f-2c3e5f795270.json
ingress:
- hostname: photos.yourdomain.com
service: http://localhost:8000
- service: http_status:404
Two rules. The first sends requests for your hostname to port 8000. The last one is the catch-all, and it is required: any request that reaches your tunnel with a hostname you did not list gets a 404 from cloudflared itself. Check the file with cloudflared tunnel ingress validate — leave the catch-all out and validation fails with “The last ingress rule must match all URLs”.
Create the DNS record
cloudflared tunnel route dns macmini-home photos.yourdomain.com
That is the proxied CNAME to <UUID>.cfargotunnel.com in your zone.
Run it
cloudflared tunnel run macmini-home
Watch for the four Registered tunnel connection lines.
To make it a service, install it the same way as the dashboard path but without a token — note that sudo changes $HOME, so point at the config explicitly:
sudo cloudflared --config /home/you/.cloudflared/config.yml service install
systemctl start cloudflared
Or get a token with cloudflared tunnel token macmini-home and use the token-based service install from Path A. When you are done with a tunnel, cloudflared tunnel delete macmini-home removes it and revokes the credentials file — it does not touch the CNAME, so remove that record under DNS, then Records, in the dashboard.
Route several services through one tunnel
A quick tunnel cannot do this part. Say the same machine also runs a Git server on port 3000 and you want SSH into it too: one tunnel handles all of it. In the dashboard, add two more routes — git.yourdomain.com to http://localhost:3000, and ssh.yourdomain.com with service type SSH to localhost:22. In a config file:
ingress:
- hostname: photos.yourdomain.com
service: http://localhost:8000
- hostname: git.yourdomain.com
service: http://localhost:3000
- hostname: ssh.yourdomain.com
service: ssh://localhost:22
- service: http_status:404
Rules are evaluated top to bottom and the first match wins. A rule can match a hostname, a path, or both. The hostname accepts a leading wildcard (*.yourdomain.com), and the path is a regular expression in Go syntax. A rule with no hostname matches every hostname, which is why the catch-all goes last.
The service can also be a Unix socket (unix:/home/you/app.sock), raw TCP (tcp://localhost:5432), RDP, or SMB. Non-HTTP services need cloudflared on the client side too, which the SSH section covers next.
Put a login in front with Cloudflare Access
Once your hostname resolves, it is public. Cloudflare Access puts a login page in front of it, at Cloudflare’s edge, before any request reaches your tunnel. It is part of Cloudflare Zero Trust (now called Cloudflare One), and the free plan covers 50 users at $0 forever — the limit counts people who log in, so a relative who visits a hundred times still takes one seat. Beyond 50 users, Pay-as-you-go is $7 per user per month (Cloudflare’s own plans page, checked November 2026).
Cloudflare recommends creating the Access application before the route, because until it exists the app is open to anyone who finds the hostname. In the dashboard go to Zero Trust, then Access controls, then Applications, and select Create new application, then Self-hosted and private, then Add public hostname. All applications deny by default, so you add an Allow policy — a rule such as “Emails ending in @yourdomain.com” or a list of specific addresses.
For identity providers, a new Zero Trust organisation comes with Cloudflare itself as the login method, restricted to members of your Cloudflare account. For family and friends, add the One-time PIN provider: they type their email, get a code, and they are in. Google, GitHub, and Microsoft are options too. Pick a session duration and save, and the next visit to your hostname shows Cloudflare’s login page first.
Also turn on Protect with Access in the tunnel’s route settings, so cloudflared itself validates the Access token on every request. And for scripts and machines that need to reach the app, Access has service tokens — a client ID and secret sent as headers — which do not consume one of the 50 seats.
SSH through the tunnel (no open port 22)
You added ssh.yourdomain.com with an ssh://localhost:22 service. Plain ssh [email protected] will not work, because Cloudflare’s edge speaks HTTP and SSH is not HTTP — cloudflared wraps it in a WebSocket, and you need cloudflared on the client side to unwrap it. The trick is an SSH ProxyCommand in ~/.ssh/config on your laptop:
Host ssh.yourdomain.com
ProxyCommand cloudflared access ssh --hostname %h
Now ssh [email protected] works from anywhere. If the hostname is behind an Access application, cloudflared access ssh opens a browser to log in the first time and caches the token. Port 22 stays closed on the router.
The private-network mode (no public hostname at all)
There is also a private mode: add a CIDR route (say 192.168.1.0/24) and install the Cloudflare One client on your devices, and they reach 192.168.1.20:8000 from anywhere as if they were at home. Hostname routes are for things other people need; private routes are for your own devices.
Cloudflare Tunnel vs ngrok vs Tailscale Funnel
| Cloudflare Tunnel | ngrok | Tailscale Funnel | |
|---|---|---|---|
| Best for | A site you want to keep running under your own domain | Development, demos, and webhooks | Fastest start if you already use Tailscale |
| Your address | Your own domain; quick tunnels get a random trycloudflare.com name |
Auto-assigned dev domain; static domain on the free plan | A name under your tailnet’s ts.net domain |
| Free tier | Tunnel on all plans, including free; 1,000 tunnels per account | 1 GB out and 20,000 HTTP requests a month, 3 endpoints, interstitial page in browsers | Free Personal plan; still in beta |
| Paid entry | $7 per user/month for Zero Trust beyond 50 users; extra tunnels $4.50 each/month beyond 1,000 | Hobbyist $10/month; Pay-as-you-go from $20/month | Standard $8 per user/month |
| Login in front | Cloudflare Access, free for 50 users | Traffic Policy with OAuth, IP rules, and rate limits | Tailnet membership only |
| SSH / raw TCP | Yes, but the client needs cloudflared too |
Yes, any client can reach raw TCP endpoints | TLS on ports 443, 8443, and 10000 only |
| Where TLS ends | Cloudflare edge | ngrok cloud by default | Your device |
Pick by job: ngrok for demos and webhooks, Tailscale Funnel if you already use Tailscale, Cloudflare Tunnel for a site that should stay up on your own domain.
Limits and rules you should know before you rely on it
- Free, with ceilings. The tunnel is included on every plan, and Access is free for 50 users. The account defaults allow 1,000 tunnels and 25 active replicas per tunnel — replicas are failover, not load balancing.
- Request size. Traffic through a public hostname is Cloudflare proxy traffic, and the Free and Pro plans cap request bodies at 100 MB (Business is 200 MB). Uploading a 2 GB video through a tunnel fails with a 413 — move big files over a private network route instead.
- Terms. No video or large-file serving through the proxy on Free, Pro, and Business plans — the terms want a paid product for that.
- What Cloudflare sees. TLS ends at Cloudflare, and every request takes an extra hop through its network — fine for a photo gallery, a deal-breaker for anything sensitive, and a latency cost for visitors on another continent.
- Tokens leak. In the dashboard a tunnel has Rotate token. After rotating, no new connector can join with the old token; running connectors stay up until you restart them.
- Port 7844 outbound must be open, UDP for QUIC or TCP for the HTTP/2 fallback. Corporate networks sometimes block it.
When something breaks
502 Bad Gateway. The tunnel is fine; cloudflared cannot reach your service — it is not running, it is on another port, or the Service URL scheme is wrong. Check curl http://localhost:8000 on the machine itself first.
Error 1033 or 1016 page. Cloudflare has the DNS record but no healthy connector behind it — cloudflared is not running, or you deleted the tunnel and left the record. cloudflared tunnel info <name> shows what is attached.
ERR_TOO_MANY_REDIRECTS. Your app redirects HTTP to HTTPS and the Service URL is http://. Switch it to https:// and set the origin server name.
403 from the app. The app checks the Host header — Vite and Astro dev servers and Ollama all do this. Set httpHostHeader.
Everything looks right and nothing arrives. Wait a minute for DNS, then check that the record is proxied (orange cloud). A grey-cloud CNAME to cfargotunnel.com does nothing.
The verdict
Reach for a Cloudflare Tunnel when you want a self-hosted app on your own domain without touching your router, when you want a stable preview hostname for a dev server, or when you want to close SSH port 22 on a server you still need to reach. It is free, it is a five-minute setup, and with Access in front it is the cheapest proper login you will ever put on a homelab service. Do not use it to serve media to other people, to sync big files, or for anything where Cloudflare seeing plaintext is a problem.
Related on HowToShipIt: Cloudflare Free Tier: What’s Actually Free (and the Limits) in 2026. Caddy Reverse Proxy Setup: Automatic HTTPS on Your VPS (2026). How to Set Up Automated VPS Backups: A Complete Guide (2026).
Further Reading & References
- Set up Cloudflare Tunnel — Cloudflare Docs
- The complete guide to Cloudflare Tunnel — Flavio Copes
- Cloudflare Access — Cloudflare
- Device to network — Cloudflare One Docs
- Cloudflare Tunnel vs ngrok vs Tailscale Funnel in 2026 — Ajay Kumar
- ngrok alternatives: 9 tunneling tools compared (2026) — ngrok
- Downloads — Cloudflare Docs
- cloudflared releases — GitHub
Prices and limits are as published on 21 November 2026 and change often — check Cloudflare’s plans page before sizing a rollout.



