Skip to content

Named Tunnel provisioning can succeed while an existing hostname points to a different tunnel ID #417

Description

@bevis7781

Bug description

When configuring a Cloudflare Named Tunnel with an existing stable hostname, provisioning can report success even though that hostname still points to a different tunnel ID.

In this state:

  • the local C2C bridge is healthy;
  • local MCP and OAuth discovery endpoints work correctly;
  • the current Named Tunnel is healthy and has active Cloudflare edge connections;
  • but the public hostname returns Cloudflare 530 / error 1033;
  • the C2C tunnel state references the current tunnel, while DNS still routes the hostname to another tunnel.

Environment

  • Windows
  • cloudflared 2026.8.3
  • Cloudflare Named Tunnel
  • A stable hostname that had previously been used with another C2C tunnel

Observed behavior

The current C2C state referenced:

tunnelName: c2c-<workspace-id>
tunnelId: <CURRENT_TUNNEL_ID>
hostname: c2c.example.com
provider: cloudflare-named

Both:

cloudflared tunnel list --output json

and:

cloudflared tunnel info <tunnel-name>

showed <CURRENT_TUNNEL_ID> as healthy, with an active connector and active edge connections.

The running cloudflared process was also using the same current tunnel.

However, the existing Cloudflare DNS record still pointed to:

c2c.example.com
CNAME
<DIFFERENT_TUNNEL_ID>.cfargotunnel.com

So the effective state was:

C2C state:
<CURRENT_TUNNEL_ID>

cloudflared tunnel list:
<CURRENT_TUNNEL_ID>

running cloudflared process:
<CURRENT_TUNNEL_ID>

stable hostname DNS target:
<DIFFERENT_TUNNEL_ID>

Public requests to /mcp and the OAuth discovery endpoints therefore returned:

HTTP 530
error code: 1033

while the equivalent local endpoints were healthy.

Suspected cause

In src/tunnel/named-provision.ts, routeDns() treats messages matching:

already exists
duplicate
exists as a cname

as benign:

if (result.ok || isBenignRouteError(`${result.stdout}\n${result.stderr}`)) return;

This appears to allow provisioning to continue when the hostname already exists, without verifying that the existing CNAME target actually points to the current tunnel ID.

As a result, the saved C2C tunnel state can reference Tunnel A while the public hostname still routes to Tunnel B.

Expected behavior

When a Named Tunnel uses an already-existing hostname:

  1. Verify that the hostname currently routes to the selected/current tunnel ID.
  2. If it already points to <CURRENT_TUNNEL_ID>.cfargotunnel.com, treat it as success.
  3. If it points to a different tunnel ID, either:
    • update the route safely; or
    • return an explicit mismatch/repair state.
  4. Ideally, c2c doctor should also detect the condition:
    current tunnel healthy + stable hostname routed to a different tunnel.

This would prevent a misleading state where the local tunnel appears healthy while the public hostname consistently returns Cloudflare 1033.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions