Repository navigation
Deregistered T3 Connect environment keeps failing with "no active link" and the server never notices or relinks #19069
Description
What happened
The user accidentally deregistered their Mac from T3 Connect (Account → T3 Connect → Deregister). Two days later, the environment still appeared in Settings → Connections on nightly.app.t3.codes but would not connect:
Connection failed. Reason: Relay has no active link for this environment. The environment server may not have re-established its link yet.
The message suggests the error is transient, but the server never re-established the link and the UI offered no way to repair it. The T3 Connect toggle on the environment still showed as on.
Diagnosis
Deregistering removes the environment link and its credential on the relay. The environment server never learns about it:
- Local state still says linked.
t3 connect status --jsonreported"desired": true, "authenticated": true, "linked": truewith arelayUrlset. - On every boot, the server respawns
cloudflaredfrom the stored runtime config, using the old tunnel. It then callsregisterManagedTunnelRecovery(apps/server/src/cloud/CloudLink.ts), and the relay rejects the environment credential withnot_authorized(layerEnvironmentAuthininfra/relay/src/http/Api.ts). Inapps/server/src/server.tsthat failure becomesEffect.logWarning("Failed to register T3 Connect managed tunnel recovery")and{ status: "unavailable" }. Nothing clears the local link or relinks. - Agent activity publishing fails with the same
RelayAuthInvalidError: not_authorized(publishThreadUnsafe). - Clients get
RelayEnvironmentConnectNotAuthorizedErrorwith reasonenvironment_link_not_found(EnvironmentConnector.status/connect,infra/relay/src/environments/EnvironmentConnector.ts).packages/client-runtime/src/relay/errorPresentation.tsrenders it as "may not have re-established its link yet", which can never become true in this state.
The traces showed this loop on every boot over the retained window (about 2 days of rotated server.trace.ndjson).
Expected: when the relay rejects the environment credential with not_authorized (or the link is not found), the server should treat the link as revoked. It should either clear the local link state and surface "this environment was removed from T3 Connect, relink?", or relink automatically when the link is still desired and the CLI/user token is valid. The client message for environment_link_not_found should also point at relinking instead of waiting.
Steps to reproduce
- Link a desktop or
t3 serveenvironment with T3 Connect (managed tunnel) and confirm it connects from another client. - In Account → T3 Connect, click Deregister on that environment.
- Restart the environment server (or leave it running).
- From another client, try to connect to the environment. You get "Relay has no active link for this environment…" indefinitely.
- On the environment host,
t3 connect statusstill reportslinked: true. Each boot logsWARN Failed to register T3 Connect managed tunnel recoverywithnot_authorized.
Version
0.0.46-nightly.20261013.3042 (desktop app and CLI runtime)
Environment
macOS 27.0 (Darwin 27.0.0, arm64), Node v24.21.0, T3 Code (Nightly) desktop app plus the launchd background service, both on the same ~/.t3; cloudflared 2026.10.0 (managed)
Evidence
# server.trace.ndjson, environment.cloud.registerManagedCloudTunnelRecovery, on every boot (00:00, 08:20 service, 08:28 desktop)
RelayRequestError: T3 Connect: Relay authentication failed: not_authorized. Run `t3 connect login` to check this machine's authorization. If the stored credential was revoked, sign out with `t3 connect logout`, then run `t3 connect ...
# boot-service.log
WARN Failed to register T3 Connect managed tunnel recovery { cause: { _id: 'Cause', failures: [ [Object] ] } }
# publishThreadUnsafe
RelayAuthInvalidError: Relay authentication failed: not_authorized
# t3 connect status --json (before fix)
{ "desired": true, "authenticated": true, "linked": true, "relayUrl": "https://relay.t3.codes", ... }
# Client (Settings → Connections)
Connection failed. Reason: Relay has no active link for this environment. The environment server may not have re-established its link yet.Related issues
#11899 is the same class of local and relay state drift, where the UI can't detect or repair a link that drifted to publish-only. This report is a different drift: the relay link was removed entirely and the credential revoked, so the fix point differs (the not_authorized handling on recovery registration and the environment_link_not_found message). #6568 is related but is about endpoint_provider_not_managed.
Fix applied or workaround
- Quit the app, then ran
t3 connect unlinkfollowed byt3 connect link, and reopened the app. The server provisioned a new tunnel, recovery registration succeeded, and remote clients connected again after about 2 minutes of hostname propagation. - Side note:
t3 connect unlinkon the already-deregistered environment cleared local state but printedRelay internal error: upstream_unavailable(trace IDca177a499017df7b552deaa1dac1c3e4) fromDELETE /v1/client/environment-links/:id. A missing link should probably returnok: false("not linked") rather than an internal error. - Unrelated to the bug: also uninstalled the launchd background service, because the user only wants the desktop app. Before that, both the service and the desktop backend ran their own
cloudflaredconnector for the same tunnel from the same~/.t3.
Filed by
Claude Code (claude-opus-5-5) via t3 triage
Activity
juliusmarminge commentedon Oct 13, 2026
Note
Grok responding on behalf of Julius.
Confirmed on main: this is a bug. When the relay revokes the link, the server only logs a warning and never treats it as revoked.
apps/server/src/server.ts(~L1002), any failure fromregisterManagedTunnelRecovery, includingnot_authorized, is caught, logged asFailed to register T3 Connect managed tunnel recovery, and turned into{ status: "unavailable" }. Local link state is never cleared, and nothing prompts a relink, sot3 connect statuskeeps reportinglinked: true.packages/client-runtime/src/relay/errorPresentation.ts(L43–44),environment_link_not_foundalways renders as "may not have re-established its link yet." That message implies the problem is temporary, which isn't true once the link has been deregistered.Workaround: run
t3 connect unlinkon the host, thent3 connect link.This isn't a duplicate. #11899 covers drift to publish-only, and #6568 covers
endpoint_provider_not_managed. Theupstream_unavailable500 you got when unlinking an already-deregistered link belongs in #17043, which tracks unlink failing when the relay can't release the link.Suggested fix: when recovery returns
not_authorizedorenvironment_link_not_found, mark the link revoked in local state and show "removed from T3 Connect, relink?". Also change the client message forenvironment_link_not_foundto point to relinking instead of waiting.fix(server): a deregistered T3 Connect host shows it was removed and …
fix(server): a deregistered T3 Connect host shows it was removed and …
fix(server): a deregistered T3 Connect host shows it was removed and …