Open History to see the last commit
1# Remote Access
2
3Use this when you want to connect to a T3 Code server from another device such as a phone, tablet, or separate desktop app.
4
5## T3 Connect troubleshooting
6
7Run `t3 connect` on the server machine to authorize it and optionally install the background service.
8The authorization message means your sign-in was saved. The server must then start and establish its
9relay link before the machine is reachable.
10
11`t3 connect status` reports saved authorization and link configuration, not a live reachability
12check. If the machine appears offline, run `t3 service status` on it and read the displayed log.
13On Linux, a service that works while SSH is open but stops after logout usually has lingering
14disabled. See [background service troubleshooting](./background-service.md#troubleshooting).
15
16Relay errors include the returned reason and trace ID when available:
17
18| Error | Next step |
19| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20| `environment_link_limit_exceeded` / managed tunnel limit reached | Unlink an unused environment in T3 Connect, then restart T3 Code on this machine. |
21| `auth_invalid` / `invalid_bearer` | Run `t3 connect login`. If the stored credential was revoked, run `t3 connect logout`, then `t3 connect` and restart the server. |
22| Expired or invalid link proof | Check the server's date and time, update T3 Code, and restart it. Include the reason and trace ID if it still fails. |
23| HTTP 403 without a recognized error response | Check relay access and any proxy or firewall restrictions. Include the Cloudflare Ray ID if one was returned; an HTTP status alone does not identify the cause. |
24| HTTP 408, 429, or 5xx | The server retries temporary failures during startup for up to ten minutes. Check network and relay availability; include the trace ID when reporting a persistent failure. |
25
26Authorization and other permanent 4xx rejections stop the startup link attempt immediately.
27After correcting them, restart the server. For the Linux background service, use
28`systemctl --user restart t3code.service`; for a foreground server, stop it and run `t3 serve` again.
29Keep the diagnostic message and trace ID when reporting a problem. Do not post authorization codes,
30pairing URLs, or the contents of the secrets directory.
31
32## Quick Pairing for a Running Server
33
34If a server is already running on this machine, mint a fresh pairing token and QR code without restarting anything:
35
36```bash
37npx t3 pair
38```
39
40`t3 pair` finds the running server (the shared `~/.t3` install, or the current worktree's dev server when run inside one), issues a one-time pairing token, and prints the pairing URL as a QR code you can scan from your phone.
41
42If the server is only bound to loopback, the printed URL is not reachable from another device. Pair over your tailnet instead:
43
44```bash
45npx t3 pair --tailscale
46```
47
48This publishes the server over Tailscale Serve HTTPS (configuring the mapping if needed — it persists until you run `tailscale serve --https=443 off`) and pairs through the `https://machine.tailnet.ts.net/` URL. Use `--tailscale-serve-port` for a different HTTPS port, `--ttl` to change the token lifetime, and `--base-dir` to target a specific data directory.
49
50If no server is running, `t3 pair` says so and points you at `npx t3 serve` or `npx t3 connect`.
51
52## Recommended Setup
53
54Use a trusted private network that meshes your devices together, such as a tailnet.
55
56That gives you:
57
58- a stable address to connect to
59- transport security at the network layer
60- less exposure than opening the server to the public internet
61
62## Enabling Network Access
63
64There are three ways to reach your server from another device: expose the desktop app's backend,
65run a headless server from the CLI, or have the desktop app launch T3 Code over SSH.
66
67### Option 1: Desktop App
68
69If you are already running the desktop app and want to make it reachable from other devices:
70
711. Open **Settings** → **Connections**.
722. Under **This environment**, toggle **Network access** on. This will restart the app and run the backend on all network interfaces.
733. The settings panel will show the default reachable endpoint, with a `+N` control when more endpoints are available. Expand it to inspect alternatives such as loopback, LAN, private-network, or HTTPS endpoints.
744. Use **Create Link** to generate a pairing link you can share with another device.
75
76Pairing codes and share links are available only in the client that created them,
77while its Connections page remains open. After you leave the page or reload it,
78create a new link to share. Other clients can see the active link's name, scopes,
79and expiry, and can revoke it if they have access management permission.
80
81The default endpoint controls the QR code and primary copy action for pairing links. You can change it from the expanded endpoint list. The preference is stored by endpoint type, so choosing the local LAN endpoint survives normal IP address changes when you move between networks.
82
83When no user default is saved, the app uses the built-in LAN endpoint for pairing links when
84available. You can set another endpoint as the default from the expanded endpoint list.
85
86- HTTPS/WSS-compatible endpoints work from `https://app.t3.codes`, but are not made the default
87 automatically.
88- Non-loopback HTTP endpoints are useful for direct LAN pairing.
89- Loopback-only endpoints are not useful for another device unless that device is the same machine.
90
91If the copied link points directly at `http://192.168.x.y:3773`, open it from a client that can reach that LAN address. If it points at `https://app.t3.codes/pair?...`, the hosted web app will save the environment and connect directly to the backend URL in the link.
92
93In the mobile app's **Add Environment** form, a numeric IP address without a scheme uses HTTP. Include `https://` explicitly when the backend is served over HTTPS.
94
95### Tailscale Endpoints
96
97When the desktop app can detect Tailscale, it adds Tailnet endpoints to the reachable endpoint list.
98
99Depending on your Tailscale setup, this may include:
100
101- the machine's `100.x.y.z` Tailnet IP
102- a MagicDNS name
103- an HTTPS MagicDNS endpoint when Tailscale Serve is configured for this backend
104
105The Tailscale HTTPS endpoint uses the clean MagicDNS URL, such as
106`https://machine.tailnet.ts.net/`, and is off until you opt in. Turn on **Enable Tailscale HTTPS**
107on the **Tailscale HTTPS** row in **Settings** → **Connections**. The desktop app restarts the
108backend with the same server-side behavior as `t3 serve --tailscale-serve`, then the server asks
109Tailscale Serve to proxy HTTPS traffic to the local backend. Turn the same switch off to stop it.
110
111The Tailscale support is an endpoint provider add-on. The core remote model still works without Tailscale: LAN HTTP endpoints, custom HTTPS endpoints, future tunnels, and SSH-launched environments all use the same saved environment and pairing flow.
112
113For `https://app.t3.codes`, prefer an HTTPS Tailnet or other HTTPS endpoint. A plain `http://100.x.y.z:3773` endpoint can still work from a desktop client or another browser page served over HTTP, but it will not work from the hosted HTTPS app because of browser mixed-content rules.
114
115### Option 2: Headless Server (CLI)
116
117Use this when you want to run the server without a GUI, for example on a remote machine over SSH.
118
119Run the server with `t3 serve`.
120
121```bash
122npx t3 serve --host "$(tailscale ip -4)"
123```
124
125`t3 serve` starts the server without opening a browser and prints:
126
127- a connection string
128- a pairing token
129- a pairing URL
130- a QR code for the pairing URL
131
132From there, connect from another device in either of these ways:
133
134- scan the QR code on your phone
135- in the desktop app, enter the full pairing URL
136- in the desktop app, enter the host and token separately
137- in the hosted web app, open a hosted pairing URL when the backend is reachable over HTTPS
138
139Use `t3 serve --help` for the full flag reference. It supports the same general startup options as the normal server command, including an optional `cwd` argument.
140
141For hosted web pairing over Tailscale HTTPS, opt in to Tailscale Serve:
142
143```bash
144npx t3 serve --tailscale-serve
145```
146
147By default this configures Tailscale Serve on HTTPS port 443 and advertises
148`https://machine.tailnet.ts.net/`. Advanced users can choose a different HTTPS port:
149
150```bash
151npx t3 serve --tailscale-serve --tailscale-serve-port 8443
152```
153
154Once paired, add projects normally: open the Command Palette and choose **Add Project**, then pick
155the environment the project lives on. Every saved environment is offered, not only the local one.
156
157### Option 3: Desktop-Managed SSH Launch
158
159Use this when you want the desktop app to start or reuse T3 Code on another machine over SSH.
160
1611. Open **Settings** → **Connections**.
1622. Under **Remote Environments**, choose **Add environment**.
1633. Select the SSH launch flow.
1644. Enter the SSH target, such as `user@example.com`.
1655. Confirm the launch. The desktop app probes the host, starts or reuses a remote T3 server, opens a local port forward, and saves the environment.
166
167After setup, the renderer connects to a local forwarded HTTP/WebSocket endpoint. The remote host still owns the actual T3 server, projects, files, git state, terminals, and provider sessions.
168
169SSH launch is a desktop feature because it needs local process and SSH access. Once the environment is paired and saved, it uses the same environment list and connection model as direct LAN, Tailscale, HTTPS, or future tunnel-backed environments.
170
171#### SSH Launch Troubleshooting
172
173The desktop SSH launcher connects with a non-interactive `sh` session, writes a small launcher script under `~/.t3/ssh-launch/<host-key>/`, starts or reuses a remote T3 server, and forwards the remote loopback port back to your desktop.
174
175The remote host must have a compatible Node.js runtime. T3 Code uses the server package's `engines.node` requirement:
176
177```text
178^22.16 || ^23.11 || >=24.10
179```
180
181During SSH launch, T3 Code first checks whether `node` is on `PATH`. If it is missing, the launcher
182looks in the usual install directories and tries to activate a version manager if it finds one
183(Volta, asdf, mise, fnm, nodenv, nvm). That covers most setups, but a version manager that only
184initializes from an interactive shell profile will not be picked up.
185
186If launch fails with `node: command not found`, a port-scan failure, or a message that the remote Node version does not satisfy the required range, SSH into the host and check the same non-interactive shell path T3 Code uses:
187
188```bash
189ssh user@example.com 'sh -lc "command -v node && node --version"'
190```
191
192If that does not print a compatible Node version, configure your version manager for non-interactive shells or install a compatible Node binary in one of the searched locations. For example, with nvm you may need a default alias:
193
194```bash
195nvm alias default 24
196```
197
198With mise, asdf, fnm, or nodenv, make sure the tool's shim directory is installed and resolves to a Node version satisfying the range above without an interactive shell.
199
200If reconnecting after an app update fails, retry the SSH launch once. The launcher now compares its generated runner script, stops stale launcher-managed remote servers, clears the SSH launch PID/port state, and starts a fresh remote server. You should not normally need to delete `~/.t3/ssh-launch` or kill `t3` processes manually.
201
202## Antigravity Google sign-in
203
204Antigravity runs and saves its Google credentials on the selected environment. You can install
205it and sign in from a remote web, desktop, or mobile client without an SSH login.
206
207Start in **Settings** > **Providers** on web or desktop. On mobile, open **Settings** >
208**Environments**, expand the environment, then choose **Set up Antigravity**.
209
210After Google sign-in, a remote browser usually reaches a `127.0.0.1` page that cannot load.
211Copy that full address into the return URL field in the same T3 Code client. Choose
212**Continue** on web or desktop, or **Complete sign-in** on mobile. Keep the address unchanged.
213Do not paste the return URL into a thread or bug report.
214
215See [Antigravity setup](./providers-antigravity.md) for installation, expiry, and account changes.
216
217## Updating a Remote Server
218
219When the T3 Code web or desktop app and a remote server use different versions, a warning appears in
220the conversation and in **Settings** → **Connections**. Follow the action shown there: T3 Code may
221be able to update and reconnect the server for you, or it may ask you to update the desktop app or
222run a copied command on the server machine.
223
224If T3 Connect cannot connect, check the date and time on both devices, then try again.
225
226Finish active work before updating because the server restarts briefly. For step-by-step guidance,
227see [Keeping T3 Code in Sync](./updating.md).
228
229On a Linux host, you can keep the server running after logout and manage it independently of the
230connection method. See [Running T3 Code in the Background](./background-service.md).
231
232## How Pairing Works
233
234The remote device does not need a long-lived secret up front.
235
236Instead:
237
2381. `t3 serve` issues a one-time owner pairing token.
2392. The remote device exchanges that token with the server.
2403. The server creates an authenticated session for that device.
241
242After pairing, future access is session-based. You do not need to keep reusing the original token unless you are pairing a new device.
243
244## Hosted Web App Pairing
245
246The hosted web app at `https://app.t3.codes` can save a remote backend in browser local storage from a URL like:
247
248```text
249https://app.t3.codes/pair?host=https://backend.example.com:3773#token=PAIRCODE
250```
251
252Use hosted pairing when the backend is reachable from the browser over HTTPS/WSS. This includes a backend behind a trusted HTTPS tunnel or another HTTPS endpoint you operate.
253
254Do not use hosted pairing for plain HTTP LAN URLs such as `http://192.168.x.y:3773`. Browsers block an HTTPS page from connecting to an insecure HTTP or WS backend. For those endpoints, use the direct pairing URL shown by the desktop app or CLI from a client that can open that HTTP URL directly.
255
256Hosted pairing does not proxy traffic through T3 Code. The browser still connects directly to the backend URL in the pairing link.
257
258## Managing Access Later
259
260Use `t3 auth` to manage access after the initial pairing flow.
261
262Typical uses:
263
264- issue additional pairing credentials
265- inspect active sessions
266- revoke old pairing links or sessions
267
268Use `t3 auth --help` and the nested subcommand help pages for the full reference.
269
270### Deregister a T3 Connect Environment
271
272Open your account menu and choose **T3 Connect** to see every environment registered to your
273account. On mobile, open **Settings** → **T3 Connect**. Choose **Deregister** to revoke an
274environment's T3 Connect access, remove any managed tunnel, and free its host space.
275
276Deregistration is an account action and does not need a connection to the environment, so it also
277works for a server that was wiped or is no longer reachable. Device-local connect and disconnect
278controls remain in **Settings** → **Connections** on web and desktop or **Settings** →
279**Environments** on mobile.
280
281## Security Notes
282
283- Treat pairing URLs and pairing tokens like passwords.
284- Prefer binding `--host` to a trusted private address, such as a Tailnet IP, instead of exposing the server broadly.
285- Anyone with a valid pairing credential can create a session until that credential expires or is revoked.
286- Hosted pairing links keep the credential in the URL hash so it is not sent to the hosted app server, but it can still be exposed through browser history, screenshots, logs, or copy/paste.
287- Use `t3 auth` to revoke credentials or sessions you no longer trust.