I am setting up streaming replication , on primary , I have already added 3following in my pg_hba.conf file
host replication replica_user xx.xx.xx.xxx/24 md5
also have done
listen_address = '*'
But while taking pg_basebackup on standby, I am getting this error:
pg_basebackup: error: connection to server at "xx.xx.xx.xxx", port 5432 failed: FATAL: Ident authentication failed for user "replica_user"
Here is my backup command:
pg_basebackup -h xx.xx.xx.xxx -D /var/lib/pgsql/data/ -U replica_user -P -v -R -X stream -C -S slaveslot1
Replication section of pg_hba.conf file:
# Allow replication connections from localhost, by a user with the
# replication privilege.
host all all 0.0.0.0/0 md5
#host replication all 3.81.214.204/32 md5
local replication all peer
host replication all 0.0.0.0/0 ident
host replication all ::1/128 ident
host replication replica_user xx.xx.xx.xxx/16 md5
Any recommendation on how can I make it work ?
Per pg_hba.conf:
The first record with a matching connection type, client address, requested database, and user name is used to perform authentication.
In your case that would be host replication all 0.0.0.0/0 ident
which fails as per the error message. You need to move host replication replica_user xx.xx.xx.xxx/16 md5
to the line above the 0.0.0.0/0 ident
line so:
# Allow replication connections from localhost, by a user with the
# replication privilege.
host all all 0.0.0.0/0 md5
#host replication all 3.81.214.204/32 md5
local replication all peer
host replication replica_user xx.xx.xx.xxx/16 md5
host replication all 0.0.0.0/0 ident
host replication all ::1/128 ident