PostgreSQL synchronous replication time out?
That isn't a problem, it's by design.

If you don't want transactions to wait until a synchronous replica acknowledges a commit, then you don't want synchronous replication. You want async replication and should simply remove the synchronous_standby_names option.

What good would synchronous replication be if it gave up when no replica was reachable? "I promise your transaction is safe on another node - oh, unless the replicas are down, in which case I'll silently break my promise."

Generally what you should be doing is setting synchronous_commit to local in transactions that don't care if the commit is synchronous, which the docs say means:


  However, the special value local is available for transactions that wish to wait for local flush to disk, but not synchronous replication.


and leaving it as on for important transactions you can't afford to lose. So only those will wait until a standby is available to replicate the changes.

See also the docs on synchronous_standby_names.

Now, you might want a way to say "Wait for up to 5 minutes for a standby to acknowledge, but proceed anyway if it hasn't by then." That's not currently supported. I'm not really convinced it's useful either.