8

I'm working via pgAdmin III on a remote PostgreSQL database. After a not so long period (say 10-15 min.) without doing anything in pgAdmin, the connection automatically expires. I therefore have a error message asking if I want to re-connect. This takes about 10 sec. and the database structure collapses, so I have to re-open the schemas I had open before.

Is there a way to change a timeout parameter somewhere so prevent the connection to expire for a longer period of time?

7

A PostgreSQL server connection dropping after 10-15 minutes is almost certainly being caused by a state-tracking firewall (possibly using Network Address Translation (NAT)) between the client and the server. Many such firewalls have default timeouts of 15 minutes (900 seconds).

The three server-side parameters, tcp_keepalives_idle, tcp_keepalives_interval, tcp_keepalives_count are designed to help in these situations. See the documentation located here: http://www.postgresql.org/docs/9.2/static/runtime-config-connection.html#GUC-TCP-KEEPALIVES-IDLE

There are also client-side parameters for this: keepalives, keepalives_idle, keepalives_interval, keepalives_count, which you can set on connection. See the documentation located here: http://www.postgresql.org/docs/9.2/static/libpq-connect.html#LIBPQ-KEEPALIVES

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.