pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: a.mitrokhin@postgrespro.ru
To: pgsql-bugs@lists.postgresql.org
Subject: Starting a PostgreSQL server on a dynamic port (parameter port=0)
Date: Thu, 10 Jul 2025 14:15:19 +0700
Message-ID: <824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru> (raw)

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?





view thread (9+ messages)  latest in thread

Message-ID: <824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru>
Permalink:  ../824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru/
Also on:    postgresql.org/message-id/824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: a.mitrokhin@postgrespro.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: Starting a PostgreSQL server on a dynamic port (parameter port=0)
  In-Reply-To: <824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox