PG Bug reporting form <noreply@postgresql.org> writes:
> There's a bug in either the .pgpass search, or the documentation thereof, in
> 13.4-4.
Perhaps, but this example doesn't prove it. Your failing case is
> root@dbserver:~# psql -d postgres -U valid_user
> psql: error: connection to server on socket
> "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication
> failed for user "valid_user"
Notice it says "peer authentication", not "password authentication".
So the password was never asked for, and the problem is that you're
not logged in as "valid_user" (rather, it looks like, as "root").
> root@dbserver:~# psql -d postgres -U valid_user -h localhost
> psql (13.4 (Ubuntu 13.4-4.pgdg20.04+1))
> SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits:
> 256, compression: off)
This is evidently going to a different pg_hba.conf line, which
might or might not be selecting password auth --- we can't see it.
regards, tom lane