We are considering a 3-node Postgres setup where 1-master and 2-standby with replication and master failover handled by repmgr and connection pooling with Pgbouncer.

Is there a way to let our application too automatically connect to the newly elected master? I dont see that happening with Pgbouncer or did I miss something? We always need our app to connect to the master db node.

1 Answer 1


What you might do is create an event notification script to be invoked upon the standby promotion, which would edit the pgbouncer databases list to point to the correct host, logging in to the pgbouncer server(s) remotely if necessary.

Alternatively, you might employ a floating IP address for the current primary and reassign it as appropriate, again using an event notification script.

In either case the application always connects to the same pgbouncer server(s), and the pooler forwards the connection to the proper primary.

  • Thank you, this looks like the solution I am looking for.
    – Oxycash
    Jan 29 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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