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 1oXk9l-0002Cw-9h for pgsql-general@arkaria.postgresql.org; Mon, 12 Sep 2022 14:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oXk9k-0005gV-4o for pgsql-general@arkaria.postgresql.org; Mon, 12 Sep 2022 14:11:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXk9j-0005gM-Q8 for pgsql-general@lists.postgresql.org; Mon, 12 Sep 2022 14:11:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXk9a-00014w-KO for pgsql-general@lists.postgresql.org; Mon, 12 Sep 2022 14:11:19 +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 28CEBB8R1611958; Mon, 12 Sep 2022 10:11:12 -0400 From: Tom Lane To: Sebastien Flaesch cc: "pgsql-general@lists.postgresql.org" Subject: Re: Resolving host to IP address In-reply-to: References: Comments: In-reply-to Sebastien Flaesch message dated "Mon, 12 Sep 2022 12:23:31 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1611956.1662991871.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 12 Sep 2022 10:11:11 -0400 Message-ID: <1611957.1662991871@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sebastien Flaesch writes: > $ psql 'postgresql://toro.strasbourg.4js.com:5437/test1?user=3Dpgsuser&s= slmode=3Dverify-ca&sslrootcert=3D./root.crt&sslcert=3D./client.crt&sslkey=3D= ./client.key' > psql: error: connection to server at "toro.strasbourg.4js.com" (127.0.1.= 1), port 5437 failed: FATAL: no pg_hba.conf entry for host "127.0.0.1", u= ser "pgsuser", database "test1", SSL encryption > What looks strange to me in this error is that first it mentions 127.0.1= .1 (ok) but then, 127.0.0.1 Linux doesn't seem to show its routing of the loopback domain in netstat output, but it's probably much like what macOS shows explicitly: $ netstat -r -n Destination Gateway Flags Netif Expire ... 127 127.0.0.1 UCS lo0 = 127.0.0.1 127.0.0.1 UH lo0 = ... That is, the entire 127/8 range is "routed" through 127.0.0.1 and will look like that to the server. I see similar entries on NetBSD. Confirming that guess, I see this behavior on RHEL8, with no particular OpenSSL involvement: $ psql -h 127.0.1.1 psql (16devel) Type "help" for help. postgres=3D# select client_addr from pg_stat_activity; client_addr = ------------- ... 127.0.0.1 ... Moral: don't try to use addresses in that range as real addresses. regards, tom lane