Skip to content

API startup should log the actual ephemeral port #8197

Description

@ak10082247-max

Problem

When the API is started with PORT=0, Node correctly asks the operating system to select an available ephemeral port, but the startup message still uses the configured value and prints:

API listening on http://localhost:0

Port 0 is not the port clients can connect to. This makes the documented startup output unusable for integration tests, preview environments, and other workflows that intentionally request an ephemeral port.

Expected behavior

After the server starts, the log should contain the actual bound port selected by the operating system. Explicit non-zero ports should continue to be reported unchanged.

Proposed fix

  • Capture the http.Server returned by app.listen().
  • Read the bound address inside the listening callback and log its actual port.
  • Add a regression test that starts the API with PORT=0 and verifies a positive reachable port is reported.

This issue is limited only to the creator of this issue. This means that only the issue author can attempt to solve this issue. If you would like to work on it, please create another issue with the same contents and refer to issue #743 for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions