patternsqlMinor
Is there a timeout option for remote access to PostgreSQL database?
Viewed 0 times
postgresqldatabasetimeoutoptionforremotethereaccess
Problem
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?
Is there a way to change a timeout parameter somewhere so prevent the connection to expire for a longer period of time?
Solution
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,
There are also client-side parameters for this:
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-IDLEThere 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-KEEPALIVESContext
StackExchange Database Administrators Q#97534, answer score: 9
Revisions (0)
No revisions yet.