T3 Connect: environment can't relink (not_authorized on tunnel recovery, then managed_endpoint_provisioning_failed) #43179
T3 Code Desktop 0.1.12, Windows 11, cloudflared 2026.10.4 (managed).
Environment ID: 3113713d-57c1-4779-bdc1-f7a147036961 (Omen-16). Another environment on the same account (Drogon) works fine.
Timeline (2026-11-26, UTC)#
- 00:42, 00:46, 00:47 Toggling T3 Connect on fails with "Could not configure environment relay access: Managed endpoint origin could not be confirmed." The server log shows
environment.cloud.registerManagedCloudTunnelRecoveryrejected withRelayRequestError/unauthorized/not_authorized, and/api/connect/relay-configreturns 503. Traces:3d4d074d250f2d8dac9ae46b5e24f12d,96c0e29fe17e21607c06311dea181c1c - 00:44
t3 connect logoutthent3 connect(fresh OAuth token), then restart. No change. - 00:50
t3 connect link("Replacing the link T3 Connect revoked"), then restart. A new relay environment credential is issued, the tunnel connects (4 connections, QUIC), and the public/.well-known/t3/environmentreturns 200. One second later the recovery registration again returnsnot_authorizedand the host marks the link revoked.t3 connect statusshows "Environment link: removed from T3 Connect" while also reporting the tunnel as reachable. Trace:8c845b5aacc90a90cb6f9d6166982c5e - 00:52 to 00:55 The mobile app reaches the host through the tunnel and calls
/api/t3-connect/mint-credentialabout 20 times (all 200, with growing backoff), but never opens a session. - 00:54 Restart, same
not_authorized. Trace:1838c71a43f3c9ba168005d0f97f525a - 00:56, 00:57 Toggling on now fails with
https://relay.t3.codes/v1/client/environment-links failed: Relay cannot provision the managed endpoint (managed_endpoint_provisioning_failed).t3 connect statusreports the endpoint address is missing from public DNS. Traces:2e34b2d59e76beaafd2e927d07c9399e,69553fe259507287f10171805bee5e59
Notes#
- Host clock, sign-in, and outbound connectivity (port 7844) are fine. The tunnel connected successfully at 00:51.
- The tunnel counter on the account went from 1/3 to 2/3 on the first failed toggle.
- It looks like the relay holds a stale revocation for this environment ID, and now can't provision its managed endpoint at all. Nothing on the host seems able to clear it.
tanstack-source added labelsbug
Note
🤖 gpt-6.1-sol responding on behalf of screen-gd
@juliusmarminge I think this is a relink regression from #39482. I have a small fix with a test.
Cause. After the relay revokes a link, the host keeps its connector running on purpose (
CloudLink.markLinkRevoked, since a 401 can be clock skew). When the user turns T3 Connect back on,EnvironmentLinker.linkfinds no active link and, since #39482, tears down the leftover allocation first. Thatdeprovisionisn't forced, so Cloudflare refuses to delete the still-connected tunnel (This tunnel has active connections).Api.tsmapsManagedEndpointDeprovisioningFailedtomanaged_endpoint_provisioning_failedwith no stage, which is why the error here has no "Failed stage". Each retry deletes the DNS record again and fails at the same point. That matches the "missing from public DNS" status in this issue and in #40210, which was opened the day after #39482 merged. Movingenvironment-idand the link key pair aside bypasses the leftover allocation by creating a new identity, but replacing the identity is unnecessary for this teardown failure. As @jdqniel confirmed below, stopping the old connector and clearing the six persisted link-state files lets the same identity relink.Fix. Pass
forceDisconnect: true(added in #42430) to that pre-link teardown. The leftover belongs to the same user and environment and has no active link, so nothing legitimate is still using it. Any caller with the account token can now drop that connector, but at this point its DNS record is already gone, and the same caller can already unlink.Verification. A new
EnvironmentLinker.test.tscase fails onmain(411e49bd3) and passes with the change. A throwaway test that wires the real linker to the real provider, with only Cloudflare faked, fails every relink atdelete-tunnelonmain. With the change, the relink disconnects, deletes and reprovisions. The relay suite passes (327 tests), as do format, lint, knip and the relay typecheck. Not tested against a deployed relay. This doesn't explain why the link was revoked in the first place; it fixes getting back in.Seen on Windows 11, T3 Code Nightly 0.1.13-nightly.20261125.5258. I'm at the open-PR limit, so here's the branch: https://github.com/screen-gd/t3code/commit/be08e8c8b655fdcbb92b86cef106dc785c0a745a (compare)
Root cause and fix found with Claude Opus 5.5 in Claude Code.Hit the exact same sequence on macOS (Apple Silicon, T3 Code Nightly
0.1.13-nightly.20261125.5258, bundledcloudflared 2026.10.4).Reproduction summary#
- After an update restart (
2026-11-26T14:50Z),hooks/wakeandpublishThreadUnsafereceived401 not_authorizedandcloud-link-revoked.binwas written, whilecloudflaredstayed connected (4 QUIC connections) to the existing managed tunnel. - Every relink attempt from the Desktop UI failed in ~0.8–1.2s with
managed_endpoint_provisioning_failed, including after a clean restart wherecloudflaredbooted back into the old tunnel:950bd8586700ee9185bd5bb3d63b2024(2026-11-26T14:59:25Z)d397caafb4deb8e072d5f3ab4e0fdb48(2026-11-26T15:07:58Z, post-restart)
Workaround (without rotating
environment-id)#You do not need to rotate
environment-idorcloud-link-ed25519-key-pair.bin. Stoppingcloudflaredby clearing the same 6 files thatdropRevokedCloudLinkremoves is enough:- Quit T3 Code completely and confirm
cloudflaredis no longer running. - Remove (or move aside) these 6 files in
~/.t3/userdata/secrets/:cloud-linked-user-id.bincloud-relay-environment-credential.bincloud-mint-ed25519-public-key.bincloud-endpoint-runtime-config.bincloud-endpoint-confirmed-origin.bincloud-link-revoked.bin
- Relaunch T3 Code (confirm
cloudflareddoes not start on boot) and enable T3 Connect in Settings.
Verification#
Relinking succeeded on the first try: the relay provisioned a new
tunnelIdunder the exact same deterministictunnelName, andcloudflaredregistered all 4 QUIC connections cleanly. This independently confirms the active-connector teardown cause above.- After an update restart (
Note
🤖 gpt-6.1-sol responding on behalf of screen-gd
@jdqniel Yes, preserving
environment-idandcloud-link-ed25519-key-pair.binis enough for this teardown failure. I checked your six-file list againstdropRevokedCloudLink; it matches. Stopping the old connector lets the relay delete its leftover tunnel and provision a replacement under the same environment identity.Our branch already addresses that same active-connector problem on the relay: it passes
forceDisconnect: trueduring pre-link teardown. It does not replace the environment ID or signing key, so no code change is needed in response to this finding. A new tunnel and relay credential are normal results of relinking, separate from changing the environment identity.My earlier wording about moving the identity files aside was too strong, and I corrected it above. Moving those two files aside and letting startup generate replacements does count as replacing the identity, even when the originals are kept in a backup folder. Your workaround shows that extra step is unnecessary here. This supports the teardown diagnosis; it does not establish why the original 401 occurred.
+1 — I’m seeing the same revoked-link →
not_authorized→managed_endpoint_provisioning_failedsequence on macOS (Apple Silicon).- T3 Code Nightly desktop and bundled server:
0.1.10-nightly.20261114.4695; managed cloudflared2026.10.4. - On November 29, the old cloudflared connector registered four QUIC connections, while relay requests were rejected with
not_authorizedand the link was marked revoked. t3 connect linkrestored account authorization and cleared the revoked state. Native desktop relinking and authenticated environment-link requests then failed with HTTP 503environment_link_unavailable, reasonmanaged_endpoint_provisioning_failed.- Local
POST /api/connect/link-proofreturned 200. Desktop trace near 2026-11-29 14:06:03 UTC:5eb6b16d1760cfddef94ad3cc7886d34. - Relay response trace IDs:
0ca94ae7c33761602aa599b357aef553,b31bcfbd68781ee4966700a8b31e0e37,63865cfdb6efb96a08a8f91c9ec3deb9.
At 16:35 UTC, status still showed enabled/authenticated, revoked=false, linked=false, and unreachable (
not_linked). That was a status check, not a fresh provisioning attempt. I haven’t tried the stop-old-connector workaround above yet, so the teardown cause is not confirmed for this host. Could maintainers check the relay provisioning spans for these response trace IDs?- T3 Code Nightly desktop and bundled server:
shivamhwp(GitHub profile, opens in a new tab) linked this to #45637
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
I hit the same sequence on macOS (T3 Code Beta 0.1.12, managed cloudflared 2026.10.4). Rotating the environment identity fixed it for me. Here is what I found in case it helps.
Symptoms#
POST /v1/environments/<id>/tunnel, and latertunnel/recovery, returned 401not_authorized. The host logged "T3 Connect no longer accepts this environment's link."POST /v1/client/environment-linksreturned 503managed_endpoint_provisioning_failed, even thoughdpop-token,statusandenvironment-link-challengesall returned 200. This continued for hours and across restarts.t3 connect statusshowed "Environment link: removed from T3 Connect", then "pending server startup", and reported that the address was missing from public DNS. Restarting,t3 connect linkand logout/login did not change anything.Likely cause in my case#
~/.t3had been migrated from another Mac, and~/.t3/usage-host-idstill contained the old machine's hostname. That meantuserdata/environment-idandsecrets/cloud-link-ed25519-key-pair.binwere created on the old machine and copied over, so both hosts shared one environment ID and one relay signing key.From the bundled server code,
t3 connect logoutandt3 connect link(clearPersistedCloudLink/dropRevokedCloudLink) clear the relay credential, the endpoint config and the revoked flag. They keepenvironment-idand the link key pair. Every relink therefore reuses the same identity, along with whatever relay-side state is attached to it. That would explain why logout and relink didn't help here.Workaround that worked#
~/.t3/userdata. Keep a backup rather than deleting them.environment-idsecrets/cloud-link-ed25519-key-pair.binsecrets/cloud-endpoint-http2-fallback.binsecrets/cloud-cli-desired-link.binsecrets/that exist (each is a.binfile):cloud-relay-environment-credential,cloud-linked-user-id,cloud-link-revoked,cloud-mint-ed25519-public-key,cloud-endpoint-runtime-config,cloud-endpoint-confirmed-origint3 connect link, then open T3 Code.On startup the server generated a new environment ID and key pair.
environment-linksreturned 200 on the first try, followed bytunnel/recovery200 andtunnel200.t3 connect statusnow reports "Environment link: provisioned" and "Other devices can reach this machine". Local threads, projects and settings were not affected, because the state DB doesn't store the host's own environment ID. Mobile clients do need to add the machine again.Suggestions#
t3 connect link --new-identity, instead of moving files by hand.~/.t3, for example whenusage-host-iddoesn't match the current hostname, and warn or offer to rotate.If the original reporter didn't migrate their data directory, the relay-side state tied to that environment ID may still be what blocks relinking. Rotating the identity may work around it as well.