If you’re looking into a Cloudflare Tunnel setup, you almost always have a concrete problem: a service is running on your home server, Raspberry Pi or small VPS, and you want it reachable from the outside. The classic route is a port forward on the router, a static IP or dynamic DNS, and a reverse proxy with a certificate. That falls apart when your connection sits behind CGNAT, and even when it works, you’re opening ports that every scanner on the planet will find within minutes.
A Cloudflare Tunnel flips the direction. A small program called cloudflared runs on your server and opens an outbound connection to Cloudflare. Visitors request your domain at Cloudflare, Cloudflare passes the request down that existing connection to you, and the response travels back the same way. Not a single port is open on your router.
We didn’t want to just rewrite the docs, we wanted to know how it behaves in practice. So on 25 November 2026 we pushed a throwaway service through a tunnel using cloudflared 2026.11.2, the current release at the time (two days old), measured it, and broke it on purpose. Three results up front:
1. From running the command to the first successful response from the internet took 6.9 seconds. Afterwards cloudflared was not listening on any third-party port, only on a local metrics endpoint at 127.0.0.1.
2. The detour through Cloudflare costs time: locally our test server answered in a median of 0.8 ms, through the tunnel in 96 ms. Irrelevant for websites and dashboards, relevant for games or databases.
3. A live event stream (Server-Sent Events) never arrived through a quick test tunnel, even though the server sent an event every second. Cloudflare now documents this too. If you need streaming, you need a proper named tunnel.

What is a Cloudflare Tunnel?
A Cloudflare Tunnel is a persistent, encrypted connection between your server and Cloudflare’s network. What makes it special is the direction: your server calls Cloudflare, not the other way round. Routers and firewalls almost always allow outbound connections, so this works even where inbound connections are impossible.
The building blocks are quick to explain:
- cloudflared is the connector, a single binary (40 MB in our test) for Linux, Windows, macOS and as a Docker image. It keeps the connection to Cloudflare open.
- The tunnel is an object in your Cloudflare account with a unique ID. Several cloudflared instances can serve the same tunnel at once, which gives you failover for free.
- Routes (formerly “public hostnames”) define which address leads to which local service, for example
wiki.example.com→http://localhost:3000. - A DNS record for the public address points to
<tunnel-id>.cfargotunnel.com. Cloudflare usually creates it for you when you add a route.
Functionally, a Cloudflare Tunnel is a reverse proxy that lives at Cloudflare instead of on your machine, plus a line through which it reaches your server. You also stop worrying about TLS certificates for the public address; Cloudflare issues them.

What it’s good for, and what it isn’t
A Cloudflare Tunnel is a great fit for services that should be publicly reachable at a normal web address: a small website on your home server, a wiki, a status dashboard, a web app for family and friends, a webhook receiver for GitHub, or a dev server you want to show a client for an afternoon. With Cloudflare Access in front, you can also require a login before a single packet reaches your server.
It’s a weaker fit for services only you use (admin panels, file shares, everyday SSH). A private VPN such as Tailscale or WireGuard is usually the cleaner answer there, because nothing is public at all. More on that in the comparison below and in our Tailscale vs WireGuard article.
Prerequisites
For a permanent tunnel you need:
- A free Cloudflare account. The tunnel itself costs nothing.
- Your own domain with DNS hosted at Cloudflare. This is the only real hurdle. You don’t have to buy the domain from Cloudflare, but its nameservers must point to Cloudflare. We explain what that means in What is DNS?.
- A machine with internet access to run cloudflared. It can be the same server that runs the service, or another machine on the same network.
- Outbound port 7844 (UDP for QUIC, TCP as fallback) should be allowed. On normal home networks it is. On locked-down corporate networks, this is where things stall.
Without a domain, you only get a Quick Tunnel: a random address under trycloudflare.com. It’s meant for trying things out and has limits we measured below.
Step 0: The five-minute test without an account (Quick Tunnel)
Before you touch your account and domain, do a dry run. It tells you within seconds whether your network lets the tunnel through at all. Install cloudflared (see step 1), then:
# Any local service, here a trivial web server on port 8080
python3 -m http.server 8080 --bind 127.0.0.1
# In a second terminal:
cloudflared tunnel --url http://127.0.0.1:8080
After a few seconds cloudflared prints an address like https://some-four-random-words.trycloudflare.com. Open it on your phone over mobile data straight away.
What we measured:
| Measurement | Result |
|---|---|
| Time until the address appeared in the log | 5.6 s |
| Time until the first 200 response from outside | 6.9 s |
| Connection protocol | QUIC, Paris data center (cdg08) |
| Ports cloudflared listened on | only 127.0.0.1:20241 (metrics) plus an unconnected UDP socket for the outbound QUIC connection |
| Process memory | about 42 MB |
| Address after restart | a new random address every time |
| Old address after stopping | error 530 |
For context: our test server is in a German data center, and the tunnel landed in Paris. A Quick Tunnel uses only one connection to Cloudflare (metric cloudflared_tunnel_ha_connections 1); a proper tunnel normally opens four connections to several data centers.
According to Cloudflare’s current documentation, Quick Tunnels also have these limits: no uptime guarantee, a maximum of 200 in-flight requests (after that, error 429), no Server-Sent Events, and a new hostname on every start. A newer option is --allowed-mail, which makes visitors enter a one-time code sent by email first:
cloudflared tunnel --url http://127.0.0.1:8080 --allowed-mail 'you@example.com'
Perfect for letting a colleague glance at your work in progress. For anything that should run longer than an afternoon, use a named tunnel.
Step 1: Install cloudflared
On Debian and Ubuntu, the official Cloudflare package repository is the best choice, because cloudflared then updates along with the rest of your system:
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
cloudflared --version
GitHub also has ready-made binaries for every platform (cloudflared-linux-amd64, -arm64 for the Raspberry Pi, .deb, .rpm, a Windows installer). One detail from our own test: the server still had a July 2026 build that had never been updated, because someone had copied it into /usr/local/bin by hand. That’s exactly why we recommend the package repository. A connector nobody updates for months is an internet-facing program nobody maintains.
For Docker there’s the official cloudflare/cloudflared image. Version 2026.11.2 was 98.7 MB in our test and runs as an unprivileged user (UID 65532) out of the box, not as root. That’s a good default.

Step 2, option A: Create the tunnel in the Cloudflare dashboard
This is the route Cloudflare itself recommends, and the easiest one for beginners. The configuration lives at Cloudflare; your server only runs cloudflared with a token.
- In the Cloudflare dashboard, go to Networking → Tunnels (older guides still call it “Zero Trust → Networks → Tunnels”).
- Click Create Tunnel and give it a name, for example
homeserver. - Under Setup Environment, choose your operating system. Cloudflare shows you a ready-made command like this:
sudo cloudflared service install eyJhIjoi...VERY-LONG-TOKEN...
- Run it on the server. It installs cloudflared as a system service that starts at boot.
- After a few seconds the tunnel should show as Healthy in the dashboard. Click Continue.
- Under Routes → Add route → Published application, pick a subdomain (
wiki), your domain from the list, and as the Service URL the local address of your service, for examplehttp://localhost:3000.
Done. https://wiki.your-domain.com now serves your service with a valid certificate and no port forwarding.
About the token: whoever has it can pose as your tunnel and accept traffic for your addresses. Treat it like a password: not in a public Git repository, not in screenshots, not in forum posts. If it leaks anyway, you can rotate the tunnel’s token in the dashboard, which makes the old one worthless.
Step 2, option B: Create the tunnel from the command line with a config file
This route is for anyone who prefers their configuration as a file on the server, for example to keep it in version control. Cloudflare calls this a “locally managed tunnel”.
# 1. Log in once: opens a link, pick your domain in the browser.
# Creates ~/.cloudflared/cert.pem
cloudflared tunnel login
# 2. Create the tunnel. Writes ~/.cloudflared/<TUNNEL-ID>.json (credentials)
cloudflared tunnel create homeserver
# 3. Let cloudflared create the DNS record
cloudflared tunnel route dns homeserver wiki.example.com
Then write the configuration to /etc/cloudflared/config.yml:
tunnel: 6ff42ae2-765d-4adf-8112-31c55c1551ef # your tunnel ID
credentials-file: /etc/cloudflared/6ff42ae2-765d-4adf-8112-31c55c1551ef.json
ingress:
- hostname: wiki.example.com
service: http://localhost:3000
- hostname: status.example.com
service: http://localhost:3001
- service: http_status:404
Copy the credentials file to /etc/cloudflared/ too and lock it down with chmod 600. Then validate, do a test run and install it as a service:
sudo cloudflared tunnel --config /etc/cloudflared/config.yml ingress validate
sudo cloudflared tunnel --config /etc/cloudflared/config.yml run homeserver
# working? Stop with Ctrl+C and install it as a service:
sudo cloudflared service install
sudo systemctl enable --now cloudflared
How systemd services work in general and how to read their logs is covered in Create a systemd service.
Ingress rules: how cloudflared checks the order
The ingress list is read top to bottom; the first matching rule wins. The last rule must be a catch-all with no hostname and no path. We tested it: cloudflared rejects a file without a catch-all at validation time:
Validation failed: The last ingress rule must match all URLs
(i.e. it should not have a hostname or path filter)
The nice part: cloudflared can tell you which rule would match any given address, without a tunnel running. With this test configuration:
ingress:
- hostname: app.example.com
service: http://localhost:3000
- hostname: "*.example.com"
path: ^/api/
service: http://localhost:8080
- hostname: ssh.example.com
service: ssh://localhost:22
- service: http_status:404
cloudflared tunnel --config config.yml ingress rule <URL> returned:
| Requested address | Matching rule | Target |
|---|---|---|
https://app.example.com/ | #0 | http://localhost:3000 |
https://foo.example.com/api/x | #1 (wildcard + path) | http://localhost:8080 |
https://foo.example.com/ | #3 (catch-all) | 404 |
https://ssh.example.com | #2 | ssh://localhost:22 |
https://other.org/ | #3 (catch-all) | 404 |
Row three is the classic surprise: the *.example.com wildcard alone isn’t enough, because the rule also requires the /api/ path. Everything else drops into the catch-all. When an address “just doesn’t work”, ingress rule is the first command to run.

Step 2, option C: Cloudflare Tunnel with Docker Compose
If your services already run in Docker, cloudflared simply joins the Compose file. The big win: the web service no longer needs any ports: at all. It’s only reachable on the internal Docker network, and cloudflared talks to it by service name.
services:
web:
image: nginx:alpine
restart: unless-stopped
# NO "ports:" needed
tunnel:
image: cloudflare/cloudflared:2026.11.2
restart: unless-stopped
command: tunnel --no-autoupdate run --token-file /run/secrets/tunnel_token
secrets:
- tunnel_token
depends_on:
- web
secrets:
tunnel_token:
file: ./tunnel-token.txt # token only, chmod 600
In the dashboard, set the Service URL to http://web:80, not localhost. Inside the cloudflared container, localhost is the container itself, not your server. That’s the most common mistake in Docker setups, and it ends in a 502.
We ran exactly this setup (with a Quick Tunnel instead of a token so no account was needed) as a throwaway project:
- After about 30 seconds the public address served the nginx welcome page with a 200.
docker compose psshowed only80/tcpfor the web service, meaning no port published on the host.- Memory according to
docker stats: cloudflared 18.1 MiB, nginx 13.6 MiB.
Pinning a version (2026.11.2 instead of latest) is deliberate: you know what’s running and you update on purpose. Just don’t forget to actually do it. For Compose basics, see our Docker Compose example.
Our hands-on test in detail
The summary is at the top; here are the details so you can put them in context.
Test 1: How much slower is the detour?
We fetched the same small HTML file ten times locally and ten times through the public tunnel address. The requests started on the same server that ran the service, so each one went from the server to Cloudflare in Paris, back down the tunnel to the server, and out again. That’s a longer path than a real visitor in Germany would take.
| Median | Fastest | Slowest | |
|---|---|---|---|
| Local (127.0.0.1) | 0.8 ms | ||
| Through the tunnel | 96.5 ms | 87.6 ms | 117.2 ms |
A 10 MB file came through the tunnel in 0.28 seconds, about 35 MB/s. Locally it took 9 ms. For a website or web app you won’t notice the detour. For anything where every millisecond matters, routing through an third-party data center is the wrong tool.
Test 2: What does your service see of the visitor?
Behind the tunnel, we ran a tiny server that simply echoes back every header it receives. The result (IP addresses truncated):
client=127.0.0.1
Host: extensive-vast-domains-stay.trycloudflare.com
Cf-Connecting-Ip: 2a01:4f8:x
Cf-Ipcountry: DE
Cf-Visitor: {"scheme":"https"}
X-Forwarded-For: 2a01:4f8:x
X-Forwarded-Proto: https
Two things matter here. First: to your service, every request comes from 127.0.0.1. If your software logs visitor IPs, rate-limits logins or relies on Fail2ban, it sees every visitor as the same client. You have to teach it to read the real address from Cf-Connecting-Ip or X-Forwarded-For, and only for connections coming from cloudflared. Second: in this example the hop between cloudflared and your service is plain HTTP. That’s fine as long as both run on the same machine or in the same Docker network.
Test 3: What happens when something fails?
| Situation | What the visitor sees |
|---|---|
| Your service is down, cloudflared is running | 502 Bad Gateway (Cloudflare page); cloudflared logs “Unable to reach the origin service … connection refused” |
| cloudflared is down | 530 (Cloudflare can’t reach any connector) |
| Both running | 200 |
This distinction saves a lot of debugging time: 502 means “the tunnel is up, but nothing answers behind it”, so check the Service URL, the port or the Docker network. 530 means “the tunnel isn’t connected”, so check whether cloudflared is running (systemctl status cloudflared) and whether outbound port 7844 gets through.
Test 4: Server-Sent Events through a Quick Tunnel
Many modern web apps push live updates via Server-Sent Events (SSE): AI chats that stream their answer word by word, dashboards with live values. Our test server sent three events one second apart. Locally they arrived at exactly 0, 1 and 2 seconds. Through the Quick Tunnel, the headers arrived after 0.10 seconds, then eight seconds of nothing until our test gave up.
That’s not a bug in your app but a documented Quick Tunnel limitation. If you test an AI chat or similar over a Quick Tunnel and the answer seems to “hang”, this is why. According to Cloudflare, named tunnels don’t have this restriction; we couldn’t measure that ourselves without an account-backed tunnel.
What we didn’t test
To be upfront: we did not create a permanent named tunnel on our own domain for this article, because that’s tied to a production Cloudflare account we didn’t want to change for a test. All measurements above come from Quick Tunnels and from offline checks with cloudflared (ingress rules, help output). The steps for options A and B follow Cloudflare’s documentation as of November 2026. We deleted all test processes, containers and the downloaded image afterwards.
Video walkthrough by Kadir Rangwala (November 2026): setting up a tunnel from scratch in the dashboard and locking it down with Cloudflare Access. Handy to follow along if you go with option A.
Lock down access: put Cloudflare Access in front of the tunnel
A tunnel makes your service reachable. It doesn’t make it secure. If there’s an app behind it with a weak login or a known vulnerability, an attacker finds it through the domain just as easily as through an open port forward. The difference: at Cloudflare, you can put a door in front of your service.
With Cloudflare Access you create a rule for an address, such as “only these three email addresses” or “only Google accounts from my family”. Visitors first see a Cloudflare login page. Only after a successful login is the request forwarded to your tunnel at all. Roughly:
- In the dashboard, go to Zero Trust → Access → Applications, then Add an application → Self-hosted.
- Enter the public address, for example
wiki.example.com. - Create a policy: action Allow, with a condition such as Emails listing your addresses.
- As a login method, One-time PIN is enough to start with: the visitor gets a code by email.
The free Zero Trust plan covers this for small groups; Cloudflare lists a limit of 50 users. Treat Access as mandatory for admin panels like Proxmox, Portainer or your router, or better still, don’t expose those panels publicly at all.
Cloudflare Tunnel vs VPN vs port forwarding

| Cloudflare Tunnel | Tailscale / WireGuard | Port forward + reverse proxy | |
|---|---|---|---|
| Open ports on the router | none | none (Tailscale) / one (WireGuard) | 80 and 443 |
| Works behind CGNAT | yes | yes (Tailscale); WireGuard only with an third-party server | no |
| Who can access | anyone with the address, optional Access login | only your devices with the app/key | anyone with the address |
| Own domain required | yes (except Quick Tunnel) | no | yes, or dynamic DNS |
| TLS certificates | handled by Cloudflare | not needed (VPN encrypts) | your job, e.g. with Caddy |
| Who sees plaintext | Cloudflare decrypts at the edge | nobody but you | nobody but you |
| Extra detour | yes, via a Cloudflare data center (~96 ms for us) | usually a direct connection | none |
| Cost | free | free for personal use | free |
| Good for | public web services, webhooks, demos | admin access, files, SSH, streaming | full control, a server with a static IP |
The “who sees plaintext” row gets skipped a lot. Cloudflare terminates TLS in its data center, looks at the request (that’s how caching, firewall rules and Access work in the first place) and then sends it down the tunnel to you. For a public website that’s fine. For a password vault or private photos, ask yourself whether you need that middleman.
Our rule of thumb: what the public should see goes through the tunnel. What only you need goes into the VPN. Plenty of homelabs run both side by side. If you’re on a VPS with its own IP, the classic reverse proxy route is often simpler and faster; see Caddy vs Nginx. And for quick access to a single port, an SSH tunnel is sometimes all you need.
SSH over Cloudflare Tunnel
You can route SSH through a tunnel as well, without opening port 22. In the config (or the dashboard), give an address the service ssh://localhost:22. On your laptop you also need cloudflared, plus this in ~/.ssh/config:
Host ssh.example.com
ProxyCommand cloudflared access ssh --hostname %h
After that, ssh user@ssh.example.com works as usual. With an Access rule in front, you also log in through the browser before the connection is established. It’s an elegant fix for servers behind CGNAT. If you already use Tailscale, though, SSH over the VPN is usually more convenient, because your laptop needs no extra tool.
Short step-by-step guide by Bryan Tutorials (July 2026) for the dashboard setup.
Common errors and how to track them down
502 Bad Gateway. The tunnel is up, but cloudflared can’t reach your service. Run curl -I http://localhost:3000 directly on the server to see whether the service answers. In Docker: use the service name instead of localhost. A Service URL with https:// when the service only speaks HTTP (or the other way round) also causes errors.
530 or “Error 1033”. Cloudflare can’t find a connected connector. systemctl status cloudflared and journalctl -u cloudflared -n 50 show whether it’s running and why not. Common causes: outbound port 7844 blocked, or the token pasted incorrectly.
Endless redirects. Your service redirects HTTP to HTTPS, but only ever sees HTTP from cloudflared. Fix: configure the service to trust X-Forwarded-Proto, or set the Service URL to https://localhost:443 directly and, with a self-signed certificate, set the matching origin server name.
Every visitor has the same IP. See test 2: the real address is in Cf-Connecting-Ip. In nginx, for example: set_real_ip_from 127.0.0.1; real_ip_header CF-Connecting-IP;.
Live updates never arrive. Quick Tunnels don’t support Server-Sent Events (test 4). With named tunnels, first check that your service disables buffering via headers.
Which rule matches? cloudflared tunnel --config /etc/cloudflared/config.yml ingress rule https://your.address/path tells you.
One more note on the firewall: since cloudflared only connects outbound, you don’t need to allow anything inbound for the tunnel. If you previously had ports 80 and 443 open for a port forward, you can close them after switching; UFW firewall setup shows how.
What not to expect from a tunnel
No protection for the app itself. If the web app has a vulnerability, it’s just as exposed through the tunnel. Updates are still your job.
No guarantee for large files and video. Cloudflare’s terms limit serving large media files over its regular network. For a Jellyfin or Plex server that only family uses, a VPN like Tailscale is the better and terms-compliant choice. If in doubt, read the current terms rather than trusting forum posts.
No independence. If Cloudflare goes down or suspends your account, your services are gone at those addresses. For a family wiki that’s tolerable; for anything business-critical, know your second route.
No substitute for backups. Sounds obvious, but a tunnel makes your server easier to reach, not more resilient.
Cloudflare Tunnel FAQ
Is Cloudflare Tunnel free?
Yes. The tunnel, cloudflared and publishing web services cost nothing. Cloudflare Access is also included in the free Zero Trust plan for small groups. Costs only kick in for larger teams or add-on products.
Do I need my own domain for Cloudflare Tunnel?
For a permanent tunnel, yes, and its DNS must be hosted at Cloudflare. Without a domain you only get Quick Tunnels with a random trycloudflare.com address that changes on every start and is meant for testing.
Does Cloudflare Tunnel work behind CGNAT?
Yes, that’s where it shines. cloudflared only makes outbound connections, and those work even when you don’t have a public IPv4 address of your own. In our test the connection also ran over IPv6 without issues.
Do I need to open a port on my router?
No. That’s the whole point. In our test cloudflared only listened on a local metrics endpoint (127.0.0.1:20241); no port was open to the outside.
Is Cloudflare Tunnel secure?
The connection between your server and Cloudflare is encrypted, and attackers can’t reach your server directly because no port is open. But Cloudflare decrypts the traffic in its data center, and your application is still public via the domain. Put Cloudflare Access in front of anything private and keep the application updated.
Can Cloudflare read my traffic?
Technically, yes. Cloudflare terminates TLS at the edge of its network in order to provide caching, firewall and Access. If you don’t want that, reach private services over a VPN like Tailscale or WireGuard.
What’s the difference between Cloudflare Tunnel and Tailscale?
Cloudflare Tunnel makes a service reachable at a public web address for any browser. Tailscale connects your own devices into a private network that strangers can’t even get near. Public stuff goes through the tunnel, private stuff into the VPN.
Can I run multiple services through one tunnel?
Yes. A tunnel can have any number of routes, each subdomain pointing to a different local service or port. You don’t need a separate tunnel per service.
Why am I getting error 502 or 530?
502 means the tunnel is up but your service behind it isn’t answering (wrong Service URL, service down, localhost instead of the service name in Docker). 530 means Cloudflare can’t find a running cloudflared. We triggered both on purpose in our test.
How do I get the real visitor IP into my logs?
cloudflared sends every request to your service from 127.0.0.1. The real address is in the Cf-Connecting-Ip and X-Forwarded-For headers. Configure your web server or app to evaluate those headers, but only for requests coming from cloudflared.
Can I stream Jellyfin or Plex over Cloudflare Tunnel?
Technically it works, but Cloudflare’s terms limit serving large media files over its regular network, and the detour costs bandwidth. For media servers that only family and friends use, we recommend a VPN like Tailscale.
How do I update cloudflared?
If you installed it from Cloudflare’s package repository, with normal system updates (apt upgrade). In Docker, bump the image version and run docker compose pull && docker compose up -d. Binaries copied by hand don’t update themselves; we saw exactly that on our own server.
Does cloudflared run on a Raspberry Pi?
Yes, there are binaries and packages for ARM (arm64, arm, armhf). cloudflared is lightweight; in our test the process used about 42 MB of RAM, and 18 MiB inside a Docker container.
Conclusion: a Cloudflare Tunnel setup is worth it, with clear roles
A Cloudflare Tunnel is the fastest way to get a service from a home server, or from a network without its own IP, cleanly onto the internet. In our test an address was live in under seven seconds without a single open port, and cloudflared is frugal at 40 to 100 MB to download and under 50 MB of RAM. With your own domain, the dashboard route and an Access rule in front, you’re done in fifteen minutes.
The limits are just as clear: every request takes a detour through a Cloudflare data center (about 96 ms for us), Cloudflare sees the decrypted traffic, and Quick Tunnels are only good for testing, not least because live event streams never arrive. Our recommendation: public web services, webhooks and demos go through the tunnel. Admin panels, files, everyday SSH and media servers go into a VPN. Whichever route you pick, the service behind it still needs updates and a backup.
If you’re just starting out and don’t have a server yet, read our home server setup guide first. There, the tunnel is one of several ways out; here you’ve got the full version.