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.
Safe staging for this asset
This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.
npx -y tokrepo@latest install 071802a4-3859-11f1-9bc6-00163e2b0d79 --target codexStages files first; activation requires review of the staged README and plan.
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.
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.
How to use
- 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
- Authenticate with your Cloudflare account:
cloudflared tunnel login
- 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.
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
Related on TokRepo
- DevOps Tools -- Infrastructure and deployment tools
- Self-Hosted Solutions -- Tools for self-hosting services securely
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
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).
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.
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.
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.
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)
- cloudflared GitHub Repository— cloudflared is the client daemon for Cloudflare Tunnel
- Cloudflare Tunnel Documentation— Cloudflare Tunnel creates encrypted outbound connections
- Cloudflare Tunnel Product Page— Free tier includes unlimited tunnels with DDoS protection
Related on TokRepo
Discussion
Related Assets
Bore — Simple Self-Hosted TCP Tunnel to Localhost
A minimal Rust CLI tool for exposing local ports to the internet through a self-hosted relay server, offering a lightweight alternative to ngrok with no account required.
Another Redis Desktop Manager — Fast Cross-Platform Redis GUI Client
Another Redis Desktop Manager (ARDM) is a free, open-source Redis GUI client for Linux, macOS, and Windows. It handles millions of keys without crashing and supports cluster mode, sentinel, SSH tunnels, and TLS connections.
OkHttp — Modern HTTP Client for Java and Kotlin
A reliable and efficient HTTP client for the JVM and Android with connection pooling, transparent GZIP, response caching, and WebSocket support.
Got — Human-Friendly HTTP Client for Node.js
Got is a lightweight, feature-rich HTTP client for Node.js with built-in retry logic, pagination, caching, and hooks for composable request pipelines.