#288·portless

Portless can assign an app port already occupied on 127.0.0.1 due to hostless free-port probe

Author: alice-watershedCreated May 6, 2026Updated Sep 23, 2026

Portless version: 0.12.0 OS: macOS

Observed behavior: Portless assigned an app port that was already listening on IPv4 loopback.

Example: Portless printed:

PORT=4163 HOST=127.0.0.1 ...

But lsof showed:

node ... TCP 127.0.0.1:4163 (LISTEN)

The child process could still start a health server, presumably via a hostless / IPv6 bind, but Portless proxies to 127.0.0.1:<port>, so readiness checks hit the stale IPv4 listener instead of the new child.

Relevant implementation detail: The free-port check appears to use net.createServer().listen(port) without a host, but the proxy later forwards to hostname: "127.0.0.1".

Expected behavior: Portless should only assign a port if the same target it proxies to is free, e.g. 127.0.0.1:<port>. Ideally it should also account for IPv6 loopback or otherwise make the bind/proxy host consistent.

Impact: This causes confusing readiness failures and orphaned child processes in process managers because the child may appear started while Portless routes to a different process.