Postgresql doesn't accept replication connection

The database name has to be replication as all does not cover replication connections.

host    replication    postgres             127.0.0.1/0               trust

The PostgreSQL documentation further says:

The value replication specifies that the record matches if a replication connection is requested (note that replication connections do not specify any particular database). Otherwise, this is the name of a specific PostgreSQL database. Multiple database names can be supplied by separating them with commas. A separate file containing database names can be specified by preceding the file name with @.


Adding the line below to pg_hba.conf and reloading worked for me. Considering the type is 'local', explicitly specifying an address isn't necessary.

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   replication     postgres                                peer

And remember to pg_ctl reload


One other possible solution here that I ran into. If you're doing logical replication and you have the DATABASE set to replication, it won't work. It needs to just get a regular parameter. The replication parameter is for physical replication, not logical replication.

Man, that one took some work to figure out. I hope this helps!