We have two servers (master, slave) and we want to use the FDW. The two databases to be connected with the FDW are both on the master (and the slave of course). When we are to CREATE SERVER we would run something like:

    OPTIONS (host 'master', dbname 'db2', port '5432');

The question is this: Does the slave create the server_db2 and connects to the master's IP address? What will happen if I break the relationship and the slave is promoted to master? I suppose it will be looking for the master to connect right?

Would connecting via and setting the method to something other than trust be a safe option?

In general the behavior of the postgres_fdw is unclear to me in a replicated environment.

1 Answer 1


You cannot really use postgres_fdw to connect from a replica server to the master, because you cannot create the foreign server on the replica, it is read only.

You'd have to run the create on the master, then rely on it replicating to the read-replica.

Even if you were to do this, it would make no sense. There is no point connecting from a replica to the master, because the replica has the same data as the master. There is no purpose to doing this.

  • There is a purpose when you lose the master and you promote the slave server.
    – adamo
    Sep 13, 2014 at 14:53
  • @adamo ... in which case you have a FDW pointing to a now-dead master? No, it still makes no sense at all. Sep 13, 2014 at 15:24
  • Which is why I am asking about pointing the FDW to and if that would not be wise in such a setup.
    – adamo
    Sep 13, 2014 at 16:23
  • I am not sure from the quesiton, but if the FDW connects to a separate cluster located on the host of the master, it could work (and possibly even make sense).
    – dezso
    Apr 15, 2015 at 9:02

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.