On Thu, Jul 10, 2025, at 10:21 AM, David G. Johnston wrote:
> On Thursday, July 10, 2025, <a.mitrokhin@postgrespro.ru> wrote:
>>
>> If you're not interested in this behavior, you'll never use it. But
>> there are cases where it can be very convenient. Why artificially
>> restrict functionality that is simple, doesn't conflict with anything,
>> and has no negative side effects?
>
> Then figure out how to do it on all the OSes we support and propose a
> patch. Maybe it’s simple enough to include. Maybe not. If it is
> simple e on an OS one cares about a shell script around pg_ctl is a
> simple way to leverage it so it’s still a fairly low priority to add
> into core.
>
I don't think it is just a matter of operating system supports it. Linux and
Windows supports port 0 but FreeBSD does not.
The RFC 63335 [1] that is referred in the IANA document [2] says:
Reserved: Reserved port numbers are not available for regular
assignment; they are "assigned to IANA" for special purposes.
Reserved port numbers include values at the edges of each range,
e.g., 0, 1023, 1024, etc., which may be used to extend these
ranges or the overall port number space in the future.
Some operating systems like Linux and Windows decided to use it to
automatically assign a free port. I don't think it is a good idea for
production. The main reason is security, we had some reports[3][4] in the past.
Some services like apache and nginx that don't allow you to use port 0.
IMO it could be supported for development purposes. However, the test suite
(pg_regress and TAP tests) already has some logic to assign a port from the
private range (49152-65535) and is capable of assigning another port if the
current port is in use. Maybe the OP has a case that the current approach is
not ideal.
[1] https://www.rfc-editor.org/rfc/rfc6335.html
[2] https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
[3] https://medium.com/@ian.barwise/socket-programming-the-bizarre-tcp-ip-port-0-saga-b5c302d04299
[4] https://nvd.nist.gov/vuln/detail/cve-2023-27567#:~:text=Description,rule%20can%20crash%20the%20kernel.
--
Euler Taveira
EDB https://www.enterprisedb.com/