pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Problem with connecting with named host parameter
3+ messages / 2 participants
[nested] [flat]

* Problem with connecting with named host parameter
@ 2021-08-27 13:29 Mike Martin <redtux1@gmail.com>
  2021-08-27 14:00 ` Re: Problem with connecting with named host parameter Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Mike Martin @ 2021-08-27 13:29 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Problem with connecting with named host parameter
  2021-08-27 13:29 Problem with connecting with named host parameter Mike Martin <redtux1@gmail.com>
@ 2021-08-27 14:00 ` Tom Lane <tgl@sss.pgh.pa.us>
  2021-08-27 16:02   ` Re: Problem with connecting with named host parameter Mike Martin <redtux1@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2021-08-27 14:00 UTC (permalink / raw)
  To: Mike Martin <redtux1@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Problem with connecting with named host parameter
  2021-08-27 13:29 Problem with connecting with named host parameter Mike Martin <redtux1@gmail.com>
  2021-08-27 14:00 ` Re: Problem with connecting with named host parameter Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-08-27 16:02   ` Mike Martin <redtux1@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Mike Martin @ 2021-08-27 16:02 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2021-08-27 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 13:29 Problem with connecting with named host parameter Mike Martin <redtux1@gmail.com>
2021-08-27 14:00 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-08-27 16:02   ` Mike Martin <redtux1@gmail.com>

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