Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uZs15-009Msr-49 for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jul 2025 14:12:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uZs12-00DJ0H-8K for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jul 2025 14:12:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uZs11-00DJ09-6S for pgsql-bugs@lists.postgresql.org; Thu, 10 Jul 2025 14:12:48 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uZs0z-006aMW-1t for pgsql-bugs@lists.postgresql.org; Thu, 10 Jul 2025 14:12:46 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id 248D3EC0176; Thu, 10 Jul 2025 10:12:44 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-07.internal (MEProxy); Thu, 10 Jul 2025 10:12:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1752156764; x=1752243164; bh=YxphKqlrCKTFztb26O451jxqJupw5DjNib8IVTIF3q8=; b= VKV7pS/nPEzWtDbh4yhwsK8QtnzQ+xnAdpvBWjYCkWCcx3VSWlDqm5JqGvhhC/9E lgvTmWIt+6V4cmmjM54jCUj9VqUDCTW5qKNqpdjtYzMAFPM9VjCF+LxlvSsMc7nW ob4jvoxooDkf6V+J+4y+RJz04u+Fd4/O5FYuNZZqaJziTFqsjIKoLDv/Ryd86dO7 9y5AuCs+9G7Iyom8Rv7/xDHGzHqb+WZU0Fm1OSi/a7Ep7IELpiKT0IUAGUmyXB73 oA2jMhqdKaHKoGcaP0MzJOCZlGAwjBot0XMBSWJgxkDSmxavWmcSjlgFpNQh75wp 14/p3ORXx8jnCrJAjh7PrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1752156764; x= 1752243164; bh=YxphKqlrCKTFztb26O451jxqJupw5DjNib8IVTIF3q8=; b=I m7bfT8mCETdCNY02aKjcE5xvhvjnURgiFKrh7GjMVkjpby2+XPV9lw61iGF3xq4B hC8pHjf8DAGkokFVXIENnbQAurwz/hEeRYH8V0D+89GaLzCDeMG+c4TACxXWK5cI qqMnS6DWLibAFWiO9b7Dw4D+8SlTs5opZsJKM7fCOf+7wokTEeZMu4Novft/jmRr W/Io19oNvUmJQSw2Q3ifJyArwrLmU7w3uqdf1oLsMSinnwrgoGSc2tSWT2LDeHDa R8Sh++RCxp+18ZPZGKIhNCd1ku3hHID0yM5D6BJLV4XQ9yXBrial5mW9Y6S1d1+p sG/deXq0Y8HuESWYfRCrA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdegtdeihecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculddqiedmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtqhertdertdej necuhfhrohhmpedfgfhulhgvrhcuvfgrvhgvihhrrgdfuceovghulhgvrhesvghulhgvrh htohdrtghomheqnecuggftrfgrthhtvghrnhepiefgheetfeeiieeuudekjeeghfegfeeh uedvhfehhfefhfeiheeiheefjeeiteefnecuffhomhgrihhnpehrfhgtqdgvughithhorh drohhrghdpihgrnhgrrdhorhhgpdhmvgguihhumhdrtghomhdpnhhishhtrdhgohhvpdgv nhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegvuhhlvghrsegvuhhlvghrthhordgtohhmpdhnsggprhgt phhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegurghvihgurdhgrd hjohhhnhhsthhonhesghhmrghilhdrtghomhdprhgtphhtthhopehrvghshhhkvghkihhr ihhllhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdgsuhhgsheslhhish htshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtoheprgdrmhhithhrohhkhhhi nhesphhoshhtghhrvghsphhrohdrrhhu X-ME-Proxy: Feedback-ID: i0c21471d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 507BF1820074; Thu, 10 Jul 2025 10:12:43 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: Tede41e0ea4201480 Date: Thu, 10 Jul 2025 11:12:22 -0300 From: "Euler Taveira" To: "David G. Johnston" , "a.mitrokhin@postgrespro.ru" Cc: "Kirill Reshke" , "pgsql-bugs@lists.postgresql.org" Message-Id: In-Reply-To: References: <824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru> Subject: Re: Starting a PostgreSQL server on a dynamic port (parameter port=0) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jul 10, 2025, at 10:21 AM, David G. Johnston wrote: > On Thursday, July 10, 2025, wrote: >>=20 >> 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=20 > patch. Maybe it=E2=80=99s simple enough to include. Maybe not. If i= t is=20 > simple e on an OS one cares about a shell script around pg_ctl is a=20 > simple way to leverage it so it=E2=80=99s still a fairly low priority = to add=20 > 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 th= e 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 su= ite (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 approac= h 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-i= p-port-0-saga-b5c302d04299 [4] https://nvd.nist.gov/vuln/detail/cve-2023-27567#:~:text=3DDescriptio= n,rule%20can%20crash%20the%20kernel. --=20 Euler Taveira EDB https://www.enterprisedb.com/