Cloudflare Zero Trust Guide
Flat isometric illustration of a large pink cloud on a dark platform above four glowing pedestals holding faceted pink gem cubes joined by faint lines.
cloudflare-tunnel

Cloudflare Tunnel Setup: Dashboard and cloudflared CLI

Set up your first Cloudflare Tunnel in the dashboard or with cloudflared. Learn how to edit a locally managed route and verify it.

By Cloudflare Zero Trust Guide Editorial · ·Updated · 6 min read

Choose the dashboard for a remotely managed Cloudflare Tunnel or the cloudflared CLI for a locally managed tunnel. If you see “This tunnel is locally managed,” change the hostname’s origin in the connector’s config.yml and start a connector with the edited file. Keep the existing DNS record if the hostname still points to the same tunnel.

Before you start: three prerequisites

  1. A domain on Cloudflare. This walkthrough uses a domain with its nameservers on Cloudflare and a single-level subdomain such as app.example.com. See Cloudflare’s local tunnel prerequisites.
  2. A connector host that can reach your app. The cloudflared process initiates outbound connections to Cloudflare. You can keep the origin’s public inbound ports closed. See how Cloudflare Tunnel connects.
  3. Outbound port 7844. Allow UDP for QUIC and TCP for HTTP/2 to region1.v2.argotunnel.com and region2.v2.argotunnel.com. If your firewall enforces SNI, also allow _v2-origintunneld._tcp.argotunnel.com, cftunnel.com, h2.cftunnel.com and quic.cftunnel.com as listed in the Cloudflare firewall guide.

With protocol set to auto, cloudflared falls back to HTTP/2 if it cannot establish QUIC over UDP. Outbound 443 is used for optional features such as update checks and connector-side Access token validation when enabled. See Cloudflare’s run parameters and the firewall guide. For a QUIC connection error, see region2 UDP connectivity troubleshooting.

Pick your path: remotely-managed or locally-managed

If you want to…ChooseWhere you change the origin
Set up and edit the tunnel in CloudflarePath AThe tunnel’s Routes tab
Set up and edit the tunnel on the connector hostPath BThe YAML file used by cloudflared

The notice means the connector reads its routes from a local configuration file. Edit ~/.cloudflared/config.yml for the account running cloudflared, or edit the file supplied with --config if the process uses a custom path. See the Cloudflare configuration file guide and the config run parameter.

Protect the hostname with Access before publishing a route

A published hostname is available to anyone on the internet until an Access application protects it.

  1. In the Cloudflare dashboard, open Zero Trust > Access controls > Applications, then select Create new application > Self-hosted and private.
  2. Select Add public hostname and enter the hostname you plan to publish, such as app.example.com.
  3. Under Access policies, add an Allow policy for the users or groups who need the app. Select the identity provider they’ll use to sign in, then select Create.

Follow the token validation step in Cloudflare’s self-hosted Access guide to reject requests that bypass Access. For policy design, see Zero Trust access and tunnels instead of VPN ingress.

Path A: the dashboard route

  1. Go to Networking > Tunnels and select Create a tunnel. Enter a name and select Create Tunnel.
  2. Choose the connector host’s operating system. Copy the installation command and run it on that host. Once the tunnel connects, select Continue.
  3. With Access in place, select your tunnel under Networking > Tunnels. In Routes, choose Add route > Published application.
  4. Enter the subdomain and domain that match your Access application. For Service URL, use the origin address as seen by the connector, such as http://localhost:8000. Select Add route.

Cloudflare requires an Advanced Certificate for a multi-level subdomain like app.internal.example.com. See Cloudflare’s dashboard setup guide.

For a private network, go to Networking > Routes and select Create route > Tunnel CIDR. Select the tunnel, enter the IP address or CIDR under Network, and select Create route. See the dashboard setup guide.

Path B: the CLI route

Create a locally managed tunnel

If you’re setting up a tunnel for the first time, install cloudflared on Ubuntu or use the package for your operating system in Cloudflare’s local setup guide. Authenticate in the browser and select your hostname when prompted. Then create the tunnel.

cloudflared tunnel login
cloudflared tunnel create my-tunnel

The first command creates cert.pem in the default .cloudflared directory. The second prints the tunnel UUID and the path to its credentials file. Create ~/.cloudflared/config.yml with those two values and your ingress rules. In this example, replace the UUID placeholder and credentials path with the values from tunnel create.

tunnel: <TUNNEL-UUID>
credentials-file: /path/to/<TUNNEL-UUID>.json
ingress:
  - hostname: app.example.com
    service: http://localhost:8000
  - service: http_status:404

Validate the file, confirm the match shows your initial origin, then add DNS and start the connector.

Change the origin for an existing hostname

Find the ingress rule for app.example.com in the file that the connector uses. The example above shows the old origin on port 8000. To move the same hostname to an app that now listens on port 8080, change the service value. The updated ingress block is:

ingress:
  - hostname: app.example.com
    service: http://localhost:8080
  - service: http_status:404

Keep the existing tunnel UUID, credentials path and any other ingress rules. Cloudflare checks rules from top to bottom, so keep the catch-all http_status:404 last. See the ingress configuration guide.

Validate the configuration and check the match

For the default configuration file:

cloudflared tunnel ingress validate
cloudflared tunnel ingress rule https://app.example.com

If your connector uses a custom configuration file, pass its path to both commands:

cloudflared tunnel --config /path/to/config.yml ingress validate
cloudflared tunnel --config /path/to/config.yml ingress rule https://app.example.com

Confirm validation succeeds and the rule check shows the file you edited. The first match should show hostname: app.example.com and service: http://localhost:8080 for the update above. This checks rule selection. Check the live URL after starting the updated connector. See the configuration file guide and Cloudflare’s ingress command definitions.

Create DNS for a new hostname

If the hostname already has a CNAME for this tunnel, keep it when changing the origin. The CNAME points to the tunnel UUID. The local ingress rule decides which service receives requests for that hostname.

For a new hostname, add the ingress rule above the catch-all and set up Access before publishing. Then run this command from the system with the account’s cert.pem. Replace app.example.com with the new hostname if you’re adding another app.

cloudflared tunnel route dns my-tunnel app.example.com

This creates the CNAME pointing to the tunnel’s <UUID>.cfargotunnel.com address. See Cloudflare’s tunnel DNS guide.

Start the connector or hand over to a replica

For a new tunnel, use the command for your configuration path. Replace my-tunnel with the tunnel you created.

cloudflared tunnel run my-tunnel

For a custom path:

cloudflared tunnel --config /path/to/config.yml run my-tunnel

For an existing tunnel, keep the old connector and its origin available during the handover. On the replica host, confirm the updated origin answers before starting the replica. With localhost in the rule, the app must listen on the replica’s own host. For this example, use Cloudflare’s origin connectivity check.

curl -v http://localhost:8080

Use the run command above to start the replica with the edited file and the same tunnel credentials.

Wait for the new replica to connect. Run cloudflared tunnel info my-tunnel to confirm it is listed among the active connectors, then stop the old connector. Active long-lived connections such as WebSockets can drop when the old connector stops. See Cloudflare’s replica guidance, configuration update steps and CLI command reference.

For a connector that starts on boot, see how to run cloudflared as a systemd service.

Verify it before you call it done

  1. Check the connector. Go to Networking > Tunnels and look for Healthy. For a local tunnel, use cloudflared tunnel info my-tunnel to confirm which connectors are active. See the dashboard setup guide and CLI command reference.
  2. Check the hostname. In the domain’s DNS records, confirm that the app’s CNAME points to this tunnel’s <UUID>.cfargotunnel.com. See Cloudflare’s tunnel DNS guide.
  3. Check the protected app. Open https://app.example.com in a fresh browser session. Expect an Access or identity-provider sign-in. Sign in as an allowed user and confirm the updated app responds. Check that an account outside the Allow policy is denied. See Cloudflare’s self-hosted Access guide.
  4. Check for direct origin exposure. Confirm the app is reachable via the tunnel and blocked via the origin’s external IP address if it has one. See Cloudflare’s firewall checks.

Error 1033 means Cloudflare couldn’t find a healthy connector. If a tunnel route returns a 502 because cloudflared can’t reach the origin, check the app’s address and port from the connector host. See Cloudflare’s common tunnel errors and the error 1033 walkthrough.

Evidence and limits. These steps are based on Cloudflare’s 2026 dashboard and local setup documentation, the November 2026 configuration guide and the cloudflared 2026.11.0 ingress command definitions. The procedure was documented without a live tunnel run.

Sources

  1. Cloudflare One docs: Cloudflare Tunnel
  2. Cloudflare One docs: Create a tunnel (dashboard)
  3. Cloudflare One docs: Create a locally-managed tunnel
  4. Cloudflare One docs: Tunnel with firewall
  5. Cloudflare Docs: Configuration file
  6. Cloudflare Docs: Run parameters
  7. Cloudflare One docs: Publish a self-hosted application to the Internet
  8. Cloudflare One docs: DNS records
  9. Cloudflare Docs: Configuration
  10. Cloudflare Docs: Useful commands
  11. Cloudflare One docs: Common tunnel errors
  12. Cloudflare cloudflared 2026.11.0: Ingress subcommands

Related