Jamie Jamie - 1 month ago 5x
Linux Question

Can I configure postgres to listen on a VIP?

I would like to be able to configure postgres to listen on specific interfaces, rather than '*', but one of them is virtual IP (VIP).

If I configure listen_addresses in postgresql.conf with the IP addresses of the interfaces, it works properly except for the VIP - postgres does not actually listen on the VIP.

However, if I configure listen_addresses to listen on '*', then when the VIP becomes active on the local machine, postgres picks it up and listens on that interface as expected.

Is there some option I am overlooking, maybe?


mwp mwp

Codifying my (apparently helpful) answer from the comments:

Assuming this is Linux, you may need to set net.ipv4.ip_nonlocal_bind so PostgreSQL can bind to the VIP whether or not it's active at startup.