ConfigsApr 14, 2026·3 min read

cloudflared — Cloudflare Tunnel Client for Exposing Services Without Opening Ports

cloudflared is the client daemon for Cloudflare Tunnel. Expose a local web app, SSH, or any TCP service to the internet through Cloudflare's edge — no public IP, no open ports, zero-trust access policies.

TL;DR
cloudflared creates encrypted tunnels from your local services to the internet without opening firewall ports or configuring DNS manually.
§01

What it is

cloudflared is the client daemon for Cloudflare Tunnel. It creates encrypted outbound connections from your local machine to Cloudflare's network, allowing you to expose a local web app, SSH server, RDP, or any TCP service to the internet without opening inbound firewall ports, configuring NAT, or managing a VPN. Cloudflare handles DNS, TLS certificates, and DDoS protection automatically.

Developers who need to share local development servers, expose self-hosted services, or set up secure remote access to machines behind NAT benefit most. cloudflared replaces tools like ngrok for permanent tunnel setups with Cloudflare's global network.

§02

How it saves time or tokens

Traditional approaches to exposing local services require port forwarding, dynamic DNS, TLS certificate management, and firewall configuration. cloudflared handles all of this with a single command. The tunnel is outbound-only, so no inbound ports need to be opened -- this simplifies network security significantly. Cloudflare's free tier includes unlimited tunnels, DDoS protection, and automatic TLS.

§03

How to use

  1. Install cloudflared:
# macOS
brew install cloudflared

# Linux
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared
chmod +x cloudflared
  1. Authenticate with your Cloudflare account:
cloudflared tunnel login
  1. Create and run a tunnel:
cloudflared tunnel create my-app
cloudflared tunnel route dns my-app myapp.example.com
cloudflared tunnel run --url http://localhost:3000 my-app

Your local app on port 3000 is now available at myapp.example.com with HTTPS.

§04

Example

# config.yml for persistent tunnel configuration
tunnel: my-app
credentials-file: /root/.cloudflared/my-app.json

ingress:
  - hostname: app.example.com
    service: http://localhost:3000
  - hostname: api.example.com
    service: http://localhost:8080
  - hostname: ssh.example.com
    service: ssh://localhost:22
  - service: http_status:404
# Quick expose without a named tunnel (temporary)
cloudflared tunnel --url http://localhost:8080
§05

Related on TokRepo

§06

Common pitfalls

  • Quick tunnels (without tunnel create) generate random hostnames and are temporary. For persistent access, create a named tunnel and configure DNS routing.
  • cloudflared must stay running for the tunnel to work. Use a process manager (systemd, launchd, PM2) to keep it alive in production.
  • Cloudflare requires you to own the domain and manage its DNS through Cloudflare. You cannot route tunnel traffic to domains on other DNS providers.

Frequently Asked Questions

Is cloudflared free?+

Yes. Cloudflare Tunnel is included in Cloudflare's free tier. You can create unlimited tunnels at no cost. The free tier includes DDoS protection and automatic TLS. Some advanced access control features require Cloudflare Zero Trust (paid plans).

How does cloudflared compare to ngrok?+

Both expose local services to the internet. cloudflared integrates with Cloudflare's network (CDN, DDoS, WAF) and supports custom domains on the free tier. ngrok provides more developer-focused features like request inspection. cloudflared is free for unlimited tunnels; ngrok's free tier has usage limits.

Can I expose SSH through cloudflared?+

Yes. cloudflared supports TCP tunnels including SSH. Configure an SSH service in your ingress rules and use 'cloudflared access ssh' on the client side to connect through the tunnel without opening port 22.

Does cloudflared work behind corporate firewalls?+

Yes, in most cases. cloudflared makes outbound HTTPS connections on port 443, which is typically allowed by corporate firewalls. No inbound ports need to be opened. Some very restrictive proxies that inspect TLS traffic may interfere.

Can I run multiple services on one tunnel?+

Yes. Use the config.yml ingress rules to route different hostnames to different local services. One cloudflared process can serve multiple services on different subdomains through a single tunnel.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets