@devries-cameron20 / t3code-1 / commits / 7c57291c4b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): a bind address Tailscale Serve refuses says to bind 127.0.0.1 or 0.0.0.0 (#35545)

Julius Marminge committed Nov 12, 2026 at 11:25 UTC 7c57291c4b642e12b8e0b330fbb005c73fe6ea8a
5 files changed +84 -7
apps/server/src/cli/pair.test.ts
+58
@@ -553,6 +553,64 @@ describe("t3 pair", () => {
553 }),
554 ).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
555 );
556 +
557 + // regression: #35517 - the macOS Tailscale apps refuse Serve targets other than
558 + // localhost, 127.0.0.1 and ::1, so a specific bind needs an explanation.
559 + it.effect("names the bind address when Tailscale refuses it as a Serve target", () =>
560 + withDescriptorServer(
561 + (origin) =>
562 + Effect.gen(function* () {
563 + const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-pair-remote-"));
564 + yield* persistServerRuntimeState({
565 + path: NodePath.join(baseDir, "userdata", "server-runtime.json"),
566 + state: yield* makePersistedServerRuntimeState({
567 + config: { host: "127.0.0.2", devUrl: undefined },
568 + port: Number(new URL(origin).port),
569 + }),
570 + });
571 + const spawner = ChildProcessSpawner.make((command) => {
572 + const { args } = command as unknown as { readonly args: ReadonlyArray<string> };
573 + const serve = args[0] === "serve";
574 + return Effect.succeed(
575 + ChildProcessSpawner.makeHandle({
576 + pid: ChildProcessSpawner.ProcessId(1),
577 + exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(serve ? 1 : 0)),
578 + isRunning: Effect.succeed(false),
579 + kill: () => Effect.void,
580 + unref: Effect.succeed(Effect.void),
581 + stdin: Sink.drain,
582 + stdout: Stream.make(
583 + new TextEncoder().encode(
584 + serve ? "" : '{"Self":{"DNSName":"pair-test.tail.ts.net."}}',
585 + ),
586 + ),
587 + stderr: Stream.make(
588 + new TextEncoder().encode(
589 + serve
590 + ? "Warning: the MacOS extension doesn't support connecting to remote destinations from non-default route\n"
591 + : "",
592 + ),
593 + ),
594 + all: Stream.empty,
595 + getInputFd: () => Sink.drain,
596 + getOutputFd: () => Stream.empty,
597 + }),
598 + );
599 + });
600 +
601 + const error = yield* provideCliTestLayers(
602 + runCli(["pair", "--base-dir", baseDir, "--tailscale"]).pipe(
603 + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
604 + Effect.provideService(HostProcess.Platform, "darwin"),
605 + Effect.flip,
606 + ),
607 + );
608 +
609 + assert.include(String(error), "127.0.0.2");
610 + }),
611 + "127.0.0.2",
612 + ).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
613 + );
614 });
615
616 describe("auth scope options", () => {
apps/server/src/cli/pair.ts
+15 -2
@@ -139,6 +139,15 @@ export class TailscaleServeFailedError extends Schema.TaggedError<TailscaleServe
139 }
140 }
141
142 +export class TailscaleServeTargetRefusedError extends Schema.TaggedError<TailscaleServeTargetRefusedError>()(
143 + "TailscaleServeTargetRefusedError",
144 + { localHost: Schema.String },
145 +) {
146 + override get message(): string {
147 + return `This Tailscale install can only proxy to localhost, and the server listens on ${this.localHost}. Restart it with \`--host 127.0.0.1\` or \`--host 0.0.0.0\`, then run this command again.`;
148 + }
149 +}
150 +
151 export class ServePortOccupiedError extends Schema.TaggedError<ServePortOccupiedError>()(
152 "ServePortOccupiedError",
153 { servePort: Schema.Number },
@@ -420,8 +429,12 @@ const resolveTailscalePairingBase = Effect.fn("pair.resolveTailscalePairingBase"
429 servePort: input.servePort,
430 ...(localTarget.localHost !== undefined ? { localHost: localTarget.localHost } : {}),
431 }).pipe(
423 - Effect.mapError(
424 - (cause) => new TailscaleServeFailedError({ servePort: input.servePort, cause }),
432 + Effect.mapError((cause) =>
433 + cause._tag === "TailscaleCommandExitError" &&
434 + cause.stderrDiagnostic === "unsupported-target" &&
435 + localTarget.localHost !== undefined
436 + ? new TailscaleServeTargetRefusedError({ localHost: localTarget.localHost })
437 + : new TailscaleServeFailedError({ servePort: input.servePort, cause }),
438 ),
439 );
440 notes.push(
apps/server/src/server.ts
+7 -5
@@ -954,11 +954,13 @@ const layerMakeServer = Layer.unwrap(
954 }),
955 ),
956 Effect.catch((cause) =>
957 - Effect.logWarning("Failed to configure Tailscale Serve", {
958 - cause,
959 - localPort,
960 - servePort: config.tailscaleServePort,
961 - }).pipe(Effect.as(null)),
957 + Effect.logWarning(
958 + cause._tag === "TailscaleCommandExitError" &&
959 + cause.stderrDiagnostic === "unsupported-target"
960 + ? `Tailscale Serve left off; this Tailscale install can only proxy to localhost, not ${localHost}. Bind --host 127.0.0.1 or 0.0.0.0 instead`
961 + : "Failed to configure Tailscale Serve",
962 + { cause, localPort, servePort: config.tailscaleServePort },
963 + ).pipe(Effect.as(null)),
964 ),
965 );
966 }),
packages/tailscale/src/tailscale.ts
+3
@@ -47,6 +47,7 @@ export const TailscaleStderrDiagnostic = Schema.Literals([
47 "not-logged-in",
48 "not-running",
49 "permission-denied",
50 + "unsupported-target",
51 "unknown",
52 ]);
53 export type TailscaleStderrDiagnostic = typeof TailscaleStderrDiagnostic.Type;
@@ -63,6 +64,8 @@ const STDERR_DIAGNOSTIC_PATTERNS: ReadonlyArray<
64 "not-running",
65 ],
66 [/permission denied|access denied|must be root|operation not permitted/i, "permission-denied"],
67 + // The macOS apps, and tailscaled without SO_MARK, proxy only to localhost, 127.0.0.1 and ::1.
68 + [/doesn't support connecting to remote destinations/i, "unsupported-target"],
69 ];
70
71 const stderrDiagnosticOf = (stderr: string): TailscaleStderrDiagnostic | undefined => {
scripts/lib/dev-share.ts
+1
@@ -19,6 +19,7 @@ const DIAGNOSTIC_EXPLANATIONS: Record<TailscaleStderrDiagnostic, string | undefi
19 "not-logged-in": "this machine is not logged into a tailnet — run `tailscale up`",
20 "not-running": "Tailscale is not running; start it and try again",
21 "permission-denied": "permission denied — `tailscale serve` may need elevated privileges",
22 + "unsupported-target": "this Tailscale install can only proxy to localhost",
23 unknown: undefined,
24 };
25