Problem with connecting with named host parameter

Started by Mike Martinover 4 years ago3 messagesgeneral
Jump to latest
#1Mike Martin
redtux1@gmail.com

Hi
I am getting the following error when I connect with hostname on localhost

psql -h capture -U <dbuser> -p 5432 <dbname>
psql: error: FATAL: no pg_hba.conf entry for host
"fe80::7285:c2ff:feb0:cd4%eth0", user "usevideo", database "usevideos", SSL
off

The hba.conf is

local all all password
# IPv4 local connections:
host all all 127.0.0.1/24 password
host all all 192.0.0.0/0 password
# IPv6 local connections:
host all all ::1/128 trust

If I change -h to ip address then it works, just not with hostname.
Connecting from another host also works.

The other thing I cant understand if the
"fe80::7285:c2ff:feb0:cd4%eth0"

This looks like an ipv6 host or block id which I caant understand.
This is with pg 11 and 12 on fedora 34

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Mike Martin (#1)
Re: Problem with connecting with named host parameter

Mike Martin <redtux1@gmail.com> writes:

I am getting the following error when I connect with hostname on localhost

psql -h capture -U <dbuser> -p 5432 <dbname>
psql: error: FATAL: no pg_hba.conf entry for host
"fe80::7285:c2ff:feb0:cd4%eth0", user "usevideo", database "usevideos", SSL
off

Evidently, your DNS setup is resolving the machine's name as a IPv6
address, whereupon PG quite legitimately doesn't find a match in
its pg_hba table. (I suppose you are using listen_addresses = "*",
else the server wouldn't even be listening on this address.)

This is with pg 11 and 12 on fedora 34

Looking at the "hosts" entry in /etc/nsswitch.conf might help figure out
exactly what's going on, but I'll bet a nickel that this is some
unhelpful systemd behavior.

regards, tom lane

#3Mike Martin
redtux1@gmail.com
In reply to: Tom Lane (#2)
Re: Problem with connecting with named host parameter

On Fri, 27 Aug 2021 at 15:00, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Mike Martin <redtux1@gmail.com> writes:

I am getting the following error when I connect with hostname on

localhost

psql -h capture -U <dbuser> -p 5432 <dbname>
psql: error: FATAL: no pg_hba.conf entry for host
"fe80::7285:c2ff:feb0:cd4%eth0", user "usevideo", database "usevideos",

SSL

off

Evidently, your DNS setup is resolving the machine's name as a IPv6
address, whereupon PG quite legitimately doesn't find a match in
its pg_hba table. (I suppose you are using listen_addresses = "*",
else the server wouldn't even be listening on this address.)

This is with pg 11 and 12 on fedora 34

Looking at the "hosts" entry in /etc/nsswitch.conf might help figure out
exactly what's going on, but I'll bet a nickel that this is some
unhelpful systemd behavior.

regards, tom lane

Very possibly.

I seem to have resolved the issue with just the following active lines in
pg_hba.conf

host all all samehost password
host all all samenet password