Skip to content

[Bug]: A server bound to a specific address leaves port 3773 when another process holds 127.0.0.1:3773 #41729

Done

Description

@daTuzzo

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

  1. Run anything that listens on 127.0.0.1:3773, for example the T3 Code desktop app.
  2. Run t3 serve --host <this machine's Tailscale IP> with no --port and no T3CODE_PORT.
  3. Read the Listening on line. Restart it and read the line again.

Expected behavior

The server binds <tailscale-ip>:3773. That address and port are free: an explicit --port 3773 binds them with no error.

Actual behavior

The server picks a random port, and a different one on each restart. Windows 11, installed 0.1.12-nightly.20261123.5151, fresh T3CODE_HOME, the desktop app holding 127.0.0.1:3773:

Command Bound
serve --host 100.x.y.z 100.x.y.z:59939, then 100.x.y.z:60033 after a restart
serve --host 100.x.y.z --port 3773 100.x.y.z:3773
serve --host 192.168.x.y 192.168.x.y:56210
serve --host 0.0.0.0 0.0.0.0:49603 (correct: localhost clients would reach the other process)
serve (no host) 127.0.0.1:56231 (correct)

The same happens on Linux: a user systemd service with T3CODE_HOST=<tailscale-ip>, on a host where another user's T3 Code holds 127.0.0.1:3773, came back on a random port after an update restart.

Cause: resolveServerConfig (apps/server/src/cli/config.ts) picks the port before it resolves the bind host, and NetService.findAvailablePort (packages/shared/src/Net.ts) probes only 127.0.0.1 and ::1. That probe is right for the default loopback bind and for wildcard binds, and wrong for a specific address. The WSL branch in apps/server/src/cli/automaticPort.ts has the same blind spot.

A client saved with a direct route (http://<tailscale-ip>:3773) cannot reach the server after the restart, and it cannot learn the new port, because the server advertises its endpoints only to clients that are already connected.

Impact

Major degradation or frequent failure

Version or commit

main at 7872c23; installed nightly 0.1.12-nightly.20261123.5151

Environment

Windows 11 (table above); Linux user systemd service

Logs or stack traces

No response

Screenshots, recordings, or supporting files

No response

Workaround

Set T3CODE_PORT=3773 in service.env, or pass --port 3773.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions