This is deeply dissatisfying. So apparently, using ports in the IANA dynamic/private port range (49152-65535) for services can lead to a self-connection issue as the kernel picks an ephermeral port and that happens to be a listen port, leading to a collision (https://sgros.blogspot.com/2013/08/tcp-client-self-connect.html). At the same time, IANA is allowed to register whatever for ports 0 through 49151. Some operating systems don't actually use the whole dynamic/private port range, leaving you with leeway. Windows, however, will just straight up fucking yoink the entire range 49152 through 65535 for ephemeral port usage (https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/default-dynamic-port-range-tcpip-chang).
If you need a throwaway port (e.g. for reverse proxying something or internal services), you thus have to use something in the range IANA can register, basically breaking the namespace promises you're supposed to make. Either you break the system's rules or break IANA rules. :haggard:
Should you use UNIX domain sockets instead? Yes. Does everything support that? No.
Conversation
Notices
-
Embed this notice
rqsd (rq@borg.social)'s status on Saturday, 30-Sep-2023 00:54:10 JST rqsd - Haelwenn /элвэн/ :triskell: likes this.