Re: Starting a PostgreSQL server on a dynamic port (parameter port=0) - Mailing list pgsql-bugs

From a.mitrokhin@postgrespro.ru
Subject Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
Date
Msg-id a03d0696a0b98a1e91947ffdefa9d6fc@postgrespro.ru
Whole thread Raw
In response to Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)  (Kirill Reshke <reshkekirill@gmail.com>)
Responses Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
List pgsql-bugs
Kirill Reshke писал(а) 2025-07-10 14:46:
> On Thu, 10 Jul 2025 at 12:15, <a.mitrokhin@postgrespro.ru> wrote:
>> 
>> Hello.
>> 
>> 
>> Postgres does not allow starting the server with port=0, which 
>> prevents
>> it from obtaining an arbitrary free port from the kernel.
>> 
>> 
>> ~$ LANG=C pg_ctl -D data -o "-c port=0" start
>> 2025-07-10 05:27:02.785 GMT [702503] FATAL:  0 is outside the valid
>> range for parameter "port" (1 .. 65535)
>> 
>> 
>> This makes it unreliable to start the server in my tests without the
>> risk of port conflicts with already running programs, unless resorting
>> to an unreliable and race-condition-prone procedure of reserving ports
>> in advance.
>> 
>> 
>> Could you please fix this?
> 
> 
> Regression tests somehow solve this problem without any patch, so why
> this should be fixed?

This has nothing to do with Postgres regression tests. The issue is
the practical benefit of using a dynamic port, which we're depriving
ourselves of.

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?



pgsql-bugs by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
Next
From: Laurenz Albe
Date:
Subject: Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)