[Bug]: T3 Connect stays down after a network change: cloudflared keeps running with zero connections and is never restarted #16258
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- On macOS, run a full-tunnel VPN client whose DNS answers with session-scoped virtual IPs. Here it is a corporate ZTNA/VPN client: while it is on,
region1.v2.argotunnel.comresolves to virtual addresses from the client's own range that only route through itsutuninterface, instead of Cloudflare's published198.41.192.xaddresses. - Run the T3 Code background service with T3 Connect enabled and confirm a phone can open the environment. cloudflared registers 4 QUIC connections to the virtual addresses it resolved at startup.
- Put the Mac to sleep, move it to another network, and wake it. Here the VPN's network extension restarted on wake and rebuilt its address map:
region1/region2.v2.argotunnel.comnow resolve to different virtual addresses, and the old ones no longer route anywhere. - Try to open the environment from the phone.
I don't have a VPN-free repro yet. The core condition is that the addresses cloudflared resolved at startup stop working while DNS starts returning new ones.
Expected behavior#
When the managed relay client is still running but has had no registered tunnel connection for a sustained period, T3 should replace it. A fresh cloudflared re-resolves the edge and reconnects. Doing that by hand restored the tunnel within 3 seconds (see Workaround).
Proposed semantics for maintainers to decide before any PR:
- Signal: use cloudflared's own readiness endpoint. Spawn it with
--metrics 127.0.0.1:0, read the bound address from itsStarting metrics server on <addr>/metricsline, and poll/ready. It returns 200 whenreadyConnections > 0and 503 otherwise. If that line never appears, do nothing, which keeps today's behavior. - Policy: poll every 30 s and count only explicit 503 responses; request errors don't count. After 6 consecutive 503s (about 3 minutes of awake time, since timers pause during sleep), kill the child and let the existing
superviseConnectorrestart it. Double the threshold after each restart that doesn't reconnect, up to about 30 minutes. Reset it once/readyreturns 200. - Open question: the exit path also queues a managed-tunnel recovery request. A watchdog restart fixes a transport problem, not a credential one, so it may be better to skip that request.
- Out of scope: reporting
runningbefore registration (#7447). Also the stale QUIC MTU case (#15897), where/readystill reports 4 connections.
Actual behavior#
Addresses are replaced with documentation ranges: 192.0.2.x stands for the virtual addresses cloudflared resolved at startup, and 203.0.113.x for the ones DNS returned after the network change. 198.41.192.7 is a real, published Cloudflare edge address.
The tunnel stayed down for 2 h 47 min, until I restarted cloudflared by hand:
- cloudflared kept dialing only the 20 edge addresses it had resolved at startup, 36 hours earlier (
192.0.2.120–192.0.2.139). The log has 461failed to dial to edge with quic: timeout: no recent network activityerrors and no successful registration. curl http://127.0.0.1:20241/readyreturned{"status":503,"readyConnections":0,...}.- The environment's relay hostname returned HTTP 530, and the phone could not connect.
- T3 did nothing. The process never exited and no registration was rejected, so neither recovery path ran.
t3 connect statusreports saved setup, not live state, so nothing on the host showed the outage either.
The network was not blocking Cloudflare Tunnel. I checked from the same Mac at the same time, using a raw QUIC version-negotiation probe and an openssl s_client handshake:
| Destination | UDP 7844 (QUIC) | TCP 7844 (TLS) |
|---|---|---|
Current DNS answer for region1/region2 (e.g. 203.0.113.143) | reply in ~10 ms | Cloudflare presents its Origin certificate |
Published edge IP 198.41.192.7 | reply in ~8 ms | Cloudflare presents its Origin certificate |
Address cloudflared kept dialing (192.0.2.121) | no reply | connection reset |
Why it never recovers:
- cloudflared resolves edge addresses only once, in
NewSupervisor(supervisor.go).edgediscovery.Edgenever refreshes them (edgediscovery.go), so it only rotates through the startup set. With normal DNS that set is Cloudflare's stable published IPs, so this rarely shows. With virtual-IP DNS the set can go stale while the process runs. - T3 restarts the connector only in two cases: when the process exits (
superviseConnector), or after 4 rejected registrations (observeConnectorOutput). Transport errors are only logged, so a live connector with zero connections is kept forever.
Any DNS that hands out session-scoped virtual IPs, such as other ZTNA clients or fake-IP modes in proxy tools, should hit the same problem. I have only reproduced it with one corporate VPN client.
Related: #7447 (a spawned but unreachable tunnel is reported as running) and #15897 (stale QUIC MTU after joining a VPN). All three treat a live cloudflared process as a working tunnel. This report covers a tunnel that worked and then went stale.
Impact#
Blocks work completely
Version or commit#
T3 Code desktop 0.0.45 and t3 service 0.0.45. Code links point to main @ f5eb250.
Environment#
macOS 27.0 (Apple Silicon); cloudflared 2026.6.0 from Homebrew (picked up from PATH); corporate full-tunnel ZTNA/VPN client;
Logs or stack traces#
# 2026-10-04 06:32Z, home network: initial registration (lines trimmed, IDs redacted)
INF Registered tunnel connection connIndex=0 ip=192.0.2.127 protocol=quic
# 2026-10-05 19:00Z, after sleep + network change: every connection drops
ERR failed to accept incoming stream requests error="failed to accept QUIC stream: timeout: no recent network activity" connIndex=0 ip=192.0.2.127
# 19:00Z-21:47Z: only the startup addresses are retried (461 times)
ERR Failed to dial a quic connection error="failed to dial to edge with quic: timeout: no recent network activity" connIndex=0 ip=192.0.2.121
# Meanwhile DNS returns different addresses
$ dscacheutil -q host -a name region1.v2.argotunnel.com
203.0.113.141 ... 203.0.113.150
# 21:47Z, after `kill <cloudflared pid>`
WARN Relay client exited; restarting
INF Registered tunnel connection connIndex=0 ip=203.0.113.143 protocol=quic
INF Registered tunnel connection connIndex=1 ip=203.0.113.204 protocol=quic
INF T3 Connect managed tunnel recovered
Screenshots, recordings, or supporting files#
No response
Workaround#
Kill only the managed cloudflared process: kill <pid>, where <pid> comes from pgrep -P <t3 serve pid> cloudflared. T3 restarts it right away, the new process re-resolves the edge, and all 4 connections registered within 3 seconds. t3 service restart also works, but it restarts the whole server.
I'm happy to send a focused PR once the intended behavior is agreed.
leeonfield(GitHub profile, opens in a new tab) added labelsbug
leeonfield(GitHub profile, opens in a new tab) added labelsneeds-triage
juliusmarminge removed labelsneeds-triage
juliusmarminge added labelsvia-triage
@juliusmarminge Kindly pay attention to this one, I tried upgrading the app on both devices, tried to turn it off on both devices and turn it on. nothing helped. i can't figure how to reconnect to my laptop
Another repro, this time with Cloudflare WARP rather than a corporate ZTNA client. Desktop Alpha 0.0.45 on macOS 26.6 (Mac mini, arm64), T3 Connect hosted by the desktop app, no background service. Homebrew cloudflared 2026.10.0.
Timeline:
- WARP (Warp mode, MASQUE, always-on) was already connected when the app started. cloudflared registered fine and served requests through the relay for ~4h.
- WARP's daemon did a disconnected → connecting → connected cycle that took ~1.3s. From that moment no request reached the host.
- 21h later the connector child is still alive,
/readyreturns{"status":503,"readyConnections":0}, and the relay hostname answers Cloudflare 530 / error 1033. Other clients getendpoint_request_failed. - Metrics over the process lifetime:
tunnel_register_success16,tunnel_register_fail{error="server_error"}4352 and climbing (+2 per 45s),{error="dup_edge_conn"}75,quic_client_closed_connections4539. So it is retrying forever, not stuck on a dead dial. - Nothing from cloudflared is on disk (#16331), so I can't see the edge's exact rejection text. QUIC gives an opaque control-stream error anyway (see the analysis in #16402), which is why
isRejectedRelayClientTunnelOutputnever fires.
Contributing factor: the edge ranges
198.41.192.0/24and198.41.200.0/24route through WARP's utun and are not in its split-tunnel exclude list.Same conclusion as above: a live-but-unregistered connector needs a readiness-based restart. Polling
/readyas proposed would have caught this within minutes.Another repro, with a different trigger: no VPN, no WARP, no sleep and no network change. The host is a headless Linux VPS in a datacenter (Hetzner, 4 vCPU / 7.7 GB). T3 runs as
t3 serveunder a systemd user unit, version 0.0.46-nightly.20261013.3066, with the pinned cloudflared 2026.10.0.Timeline (UTC):
- 15:10: fresh connector, 4 connections registered over QUIC.
- 16:04–16:12: repeated QUIC session closes on connIndex 1 and 2,
Application error 0x0 (remote), plus onetimeout: no recent network activity. Each re-registered within 10–30 s. - 16:12:44: last line cloudflared ever logged (
Registered tunnel connection connIndex=2 ... protocol=quic). After that, total silence for 98 minutes. Same pid throughout, and the local origin kept answering 200. - During the silence, clients showed "reconnecting". A few relay requests still reached the origin (two websockets at about 16:46 and 17:41 lived about 160 s each and then dropped), so it was degraded and flapping rather than fully dead.
- 17:50: manual restart of the service. 4 connections registered within 3 s.
Notes that may matter for the
/readywatchdog design:- We did not capture
/readyduring the outage, so I can't say whether it went to 503. Since some traffic still got through, it may have kept reporting connections, which is closer to the #15897 shape than the zero-connection one. An end-to-end probe of/.well-known/t3/environmentthrough the relay hostname caught it where process liveness didn't. - Workaround we now run: an external timer that checks both that probe and
/ready, and restarts the service after 2 consecutive failures (max once per 15 min). We also forceTUNNEL_TRANSPORT_PROTOCOL=http2(see #16344). - Host had swap mostly full and some IO pressure, so host slowness may have contributed. There was no change in pressure at 16:12, though.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Triage#
Thanks for the detailed timeline, logs, and the proposed watchdog, @leeonfield! The
/readyandreadyConnectionsevidence made this very clear.What I found#
CloudManagedEndpointRuntime(apps/server/src/cloud/ManagedEndpointRuntime.ts) only replaces the managedcloudflaredin two cases: the process exits (superviseConnector), or the edge rejects the tunnel four times (observeConnectorOutput:Failed to get tunnel, missing record, invalid secret). A live process whose dials time out is logged as a transport warning and kept, andrunningonly means the child is alive. That matches the 2h47m outage with/readyat 503 andreadyConnections: 0.NewSupervisor→ResolveEdge) andedgediscovery.Edgeonly rotates within that set. That's fine with published anycast addresses but not with session-scoped virtual IPs from a ZTNA client, so the connector stays stuck until restarted.T3 Connect managed tunnel recovered).runningbefore first registration) or #15897 (stale QUIC MTU where/readystays 200).Likely fix area#
One option along the lines you proposed, with details a maintainer may want to weigh:
--metrics 127.0.0.1:0(loopback only, since the metrics server also exposes debug endpoints) and read the bound address from that child'sStarting metrics server on …line, rather than assuming the default port 20241, which may belong to another process./readyperiodically, count only consecutive HTTP 503s (a 200 resets the streak, request errors leave it unchanged), kill the child after a threshold, and back off across restarts that never reach a 200, tracked outside the child's lifetime.A maintainer will decide on the fix direction.