Setup VIP for PostgreSQL Replication I have been assigned a task to setup Streaming replication in Postgresql. I am not a DBA by profession, doing this thing for the first time.  I have set up replication, now as we don't want to change the database connection string in the application during failover, I need to set up VIP for the same so that I provide only one IP in the connection string.

I have used this article for setting and testing VIP. I am able to setup VIP on a machine and able to connect PostgreSQL with this VIP. But when I tried to assign the same VIP to the slave server, i got an error that cannot assign requested address bind.

I need help to setup VIP and make it work with streaming replication so that applications always point to the master server i.e. point to new master after failover.

lets suppose a case , if VIP is assigned to master and that VM goes down, how will I unassign VIP from old master and assign to a new master.
The VIP should only be assigned to one host: in a replication system, it must be assigned to the current primary/master server. Only failover or switchover should move the VIP to the standby/slave server.