Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: a(dot)mitrokhin(at)postgrespro(dot)ru
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
Date: 2025-07-10 07:46:55
Message-ID: CALdSSPgNJWenx+wGt2pL4oFcuZw21=C3B8AB27b_kayuWZB6yw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, 10 Jul 2025 at 12:15, <a(dot)mitrokhin(at)postgrespro(dot)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?

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message a.mitrokhin 2025-07-10 08:29:53 Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
Previous Message a.mitrokhin 2025-07-10 07:15:19 Starting a PostgreSQL server on a dynamic port (parameter port=0)