You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sandbox supervisor keeps listening on loopback ports after the application closes them #5300
Inside a sandbox, once a process binds a loopback port and then closes it, the port keeps accepting connections. The supervisor (PID 1, openshell-sandbox) appears to keep a listener on the port after the original process has released it, so a later connect() to 127.0.0.1:<port> succeeds even though no application is listening.
This breaks any tool that probes for a free port by binding, closing, then checking that nothing answers. Each probe makes the port it tested look busy for good. Examples:
T3 Code's remote SSH launcher scans 3773–3972 this way and fails on every port with "Failed to find an available port on the remote host".
Dev servers that probe for a free port (bind → close → connect check) drift upward or give up.
A server restarted on the port it used before cannot be told apart from a live one by a connect probe.
Steps to reproduce
Observed on OpenShell 0.1.3 (macOS host, linux/arm64 sandbox) through T3 Code's port picker. Minimal repro of the same pattern:
Expected: connect_ex returns ECONNREFUSED (111) once the only listener has closed.
Actual: the connection is accepted, and the listener belongs to the supervisor (PID 1, openshell-sandbox), not to any application process.
Ports that no sandbox process has ever bound refuse connections as expected.
Expected behavior
The supervisor stops listening on a loopback port once the sandbox process that bound it has closed it, or the forwarding/ingress behavior that needs the listener is opt-in per port (for example only ports declared through openshell service expose or sandbox forward).
Context
Found while connecting the T3 Code desktop app to an OpenShell sandbox over SSH (downstream: Swisscom Saito). The workaround is to start the server ourselves on a port found with a connect-only probe, which never binds and so never poisons a port.
Activity