CLI to manage Cloudflare Tunnels in a single command. Automates the full lifecycle: create tunnel + configure DNS + generate config + run.
No more manual steps. One command to create, one to run.
Setting up a named tunnel with cloudflared requires multiple steps:
cloudflared tunnel create namecloudflared tunnel route dns name hostname- Manually create a
.ymlfile with the tunnel ID, credentials path, and ingress rules cloudflared tunnel --config file.yml run
cftunnel reduces this to:
cftunnel create my-api example.com 3000
cftunnel run my-api-
Install cloudflared:
brew install cloudflared
Or see other installation methods.
-
Log in to your Cloudflare account:
cloudflared tunnel login
This will open a browser window where you select the domain you want to use with your tunnels.
brew tap usedilver/tap
brew install cftunnelcurl -fsSL https://raw.githubusercontent.com/usedilver/cloudflare-tunnel-cli/main/cftunnel -o ~/.local/bin/cftunnel
chmod +x ~/.local/bin/cftunnelMake sure
~/.local/binis in yourPATH. If not, add this to your shell profile:export PATH="$HOME/.local/bin:$PATH"
cftunnel create my-api example.com 3000In a single step, this:
- Creates the tunnel in Cloudflare (or reuses an existing one)
- Configures the DNS route (
my-api.example.com) - Generates the
.ymlconfiguration file
cftunnel run my-apicftunnel runShows all configured tunnels and lets you choose which one to start:
Available tunnels:
1) my-api https://my-api.example.com :3000
2) my-web https://my-web.example.com :8080
3) testing https://testing.example.com :5000
Select tunnel (1-3) or 'q' to quit:
cftunnel listcftunnel port my-api 8080cftunnel edit my-apicftunnel delete my-apiRemoves the tunnel from Cloudflare, deletes the config file and credentials.
cftunnel status| Command | Description |
|---|---|
cftunnel create <name> <domain> <port> |
Create tunnel + DNS route + config |
cftunnel run [name] |
Run a tunnel (interactive if no name given) |
cftunnel list |
List locally configured tunnels |
cftunnel delete <name> |
Delete tunnel and cleanup files |
cftunnel edit <name> |
Open tunnel config in your editor |
cftunnel port <name> <port> |
Change a tunnel's port |
cftunnel status |
Show tunnels registered in Cloudflare |
cftunnel help |
Show help |
| Variable | Default | Description |
|---|---|---|
CLOUDFLARED_DIR |
~/.cloudflared |
Directory where configs are stored |
For more details on how Cloudflare Tunnels work, check the official docs:
- Cloudflare Tunnel overview
- Create a tunnel (Dashboard)
- Create a locally-managed tunnel (CLI)
- Tunnel run parameters
- macOS (auto-opens browser with
open) - Linux (auto-opens browser with
xdg-open)
Contributions are welcome! Feel free to open issues and pull requests.