Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwVvx-00072W-EG for pgsql-general@arkaria.postgresql.org; Thu, 24 Jun 2021 20:26:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lwVvv-0002cv-J2 for pgsql-general@arkaria.postgresql.org; Thu, 24 Jun 2021 20:26:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwVvv-0002cm-AF for pgsql-general@lists.postgresql.org; Thu, 24 Jun 2021 20:26:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwVvp-0001L6-0R for pgsql-general@lists.postgresql.org; Thu, 24 Jun 2021 20:26:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15OKQSg62685747; Thu, 24 Jun 2021 16:26:29 -0400 From: Tom Lane To: "Peter J. Holzer" cc: pgsql-general@lists.postgresql.org, Jerry LeVan Subject: Re: Psql wants to use IP6 when connecting to self using tcp... In-reply-to: <20210624154227.GA22620@hjp.at> References: <20210623175127.GB27765@hjp.at> <2558211.1624494813@sss.pgh.pa.us> <20210624154227.GA22620@hjp.at> Comments: In-reply-to "Peter J. Holzer" message dated "Thu, 24 Jun 2021 17:42:27 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2685745.1624566388.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 24 Jun 2021 16:26:28 -0400 Message-ID: <2685746.1624566388@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Peter J. Holzer" writes: > On 2021-06-23 20:33:33 -0400, Tom Lane wrote: >> It's quite odd that nslookup isn't agreeing with glibc's name >> resolution code. > AFAIK nslookup uses only DNS. Glibc uses all methods in nsswitch.conf. Ah, right. So looking at a Fedora 34 installation, I see in /etc/nsswitch.conf: ... hosts: files myhostname resolve [!UNAVAIL=3Dreturn] dns ... /etc/hosts is pretty innocuous: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdom= ain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdom= ain6 On the other hand, "man nss-myhostname" says o The local, configured hostname is resolved to all locally configured IP addresses ordered by their scope, or -- if none a= re configured -- the IPv4 address 127.0.0.2 (which is on the local loopback) and the IPv6 address ::1 (which is the local host). so it might be that that's what is causing the weird behavior. On this machine, with a recent PG build installed but no running server, I see: $ psql -h rpi3 psql: error: connection to server at "rpi3" (fe80::ba27:ebff:fe51:3b34), p= ort 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connection= s? connection to server at "rpi3" (192.168.1.61), port 5432 failed: Connectio= n refused Is the server running on that host and accepting TCP/IP connection= s? so indeed *something* is injecting an IPv6 address that I didn't ask for. However, I see the same two addresses probed with the fully-qualified machine name, so it's not quite like Jerry's result. regards, tom lane