You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
POSTGRES_HOST_AUTH_METHOD
This optional variable can be used to control the auth-method for host connections for all databases, all users, and all addresses. If unspecified then md5 password authentication is used. On an uninitialized database, this will populate pg_hba.conf via this approximate line:
echo "host all all all $POSTGRES_HOST_AUTH_METHOD" >> pg_hba.conf
Yes, this is happens and at the bottom of pg_hba.conf there is a line host all all all md5 is present. The problem is that we still have standard row above
# IPv4 local connections:
host all all 127.0.0.1/32 trust
And because it is above it gets applied first for connections from localhost. And it does allow to login without any passwod specified.
Postgres official docs:
The first record with a matching connection type, client address, requested database, and user name is used to perform authentication.
Is this overlooked or IPv4 local connections aren't considered as a "host" ones?
psql -h localhost postgres postgres
The text was updated successfully, but these errors were encountered:
localhost doesn't mean anything in a Docker context. If you're running your database with localhost being the only thing accessible inside Docker, you might as well not be running it at all (since localhost is only accessible from directly within the PostgreSQL container itself).
@wglambert
Thank you for clarifications. I didn't know that -h localhost still will use socket and not a TCP/IP connection.
Actually wondering how is then possible to trigger TCP/IP connection via psql from localhost? Documentation says if -h is not specified then "local socket" is used. And I was assuming that otherwise we will not use socket but TCP/IP
$ psql --help
Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "local socket")
Description on docker image
Yes, this is happens and at the bottom of
pg_hba.conf
there is a linehost all all all md5
is present. The problem is that we still have standard row above# IPv4 local connections: host all all 127.0.0.1/32 trust
And because it is above it gets applied first for connections from localhost. And it does allow to login without any passwod specified.
Postgres official docs:
Is this overlooked or
IPv4 local connections
aren't considered as a "host" ones?The text was updated successfully, but these errors were encountered: