I'm running a Postgres database on 5432, and pgBouncer on 6432.
All of my scripts point to 6432, but we have a large legacy code base that points to 5432, which we'd like to have user pgBouncer as well.
The best way we've come up with to do this is to run Postgres on 4432 and pgBouncer on 5432 and 6432. Unfortunately we can only find a way to have pbBouncer listen on one port.
Is it possible to have pgBouncer listen on two ports?
We also tried using IPTables to forward 6432 to 5432 transparently, but it didn't work:
sudo iptables -t nat -I PREROUTING -p tcp --dport 6432 -j REDIRECT --to-ports 5432
sudo iptables -t nat -I OUTPUT -p tcp -o lo --dport 6432 -j REDIRECT --to-ports 5432
Still gives this error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.6432"?
Any suggestions (aside from "update the legacy code base", which is being reserved as a last resort)?