Error code

Node.js ERR_SOCKET_BAD_PORT

NODE.JSERR_SOCKET_BAD_PORT
Runtime Error Code· An error code from a programming runtime or package manager, like Node.js or npm.

What it means

A network socket operation specified a port number that is outside the valid range of 0 to 65535.

How to fix it

  1. Validate port numbers before passing them to net or http APIs.
  2. Use environment variable parsing with a default fallback.
  3. Clamp the value with Math.max(0 Math.min(65535 port)).

Not affiliated with Node.js. Answer summarized from the manufacturer's manual linked above; consult that source for the authoritative procedure.