I'm trying to set up streaming replication between two Postgres servers. The master server's pg_hba.conf file is configured this way:

host    replication     ${REP_USER}               md5
host    ${DB_NAME}      ${DB_USER}               md5

And the initializer script in the slave container runs the following at startup to connect to it:

cat > ~/.pgpass <<EOS
chmod 0600 ~/.pgpass

echo "Cleaning up old cluster directory"
rm -rf ${PGDATA}/*

echo "Starting base backup as replicator"
pg_basebackup -h ${MASTER_PORT_5432_TCP_ADDR} -D ${PGDATA} -U ${REP_USER} -vPw

All the env values are set. The problem is I keep getting this error:

pg_basebackup: could not connect to server: fe_sendauth: no password supplied

I'm not sure why this keeps happening. I have the password file in place with the right permissions. I also have the password in the recovery file, which doesn't get created because pg_basebackup fails all the time.

Any help would be appreciated...


Your issue is that your .pgpass file is missing the database field, and all fields are required (although you can use it * for any match). As you are using pg_basebackup (that uses the replication protocol), you need supply that as "replication":

cat > ~/.pgpass <<EOS

Using * for the database field would work too, but replication is more strict.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.