I'm monitoring my PostgreSQL clients using a periodic netstat -an | grep 5432 | grep EST to check the ESTABLISHED status of the connection every 5 minutes. I have noticed that all of the connections become TIME_WAIT after around minutes, and then a new connection is re-opened (the client port changes), forming a new ESTABLISHED connection. This behavior persists regardless of the status or activity of the postgres client.

Any thoughts on what might be causing this recurring reconnection on the clients? I've tried setting the tcp_keepalives_idle to no avail.

  • 1
    You should consult the logs of the database server and the application. Perhaps there is a timeout on the server (but that would not apply to idle connections unless they have an open transaction), perhaps it is a connection pool, perhaps it is an ill-configured firewall. Aug 27, 2019 at 8:22
  • 1
    The description fits the clients themselves initiating these reconnections. Aug 28, 2019 at 13:48
  • @LaurenzAlbe Turns out you're right! It does use a connection pool (HikariCP), and the maxLifeTime and idleTimeout configurations are causing the reconnection. Fixed!
    – edrichhans
    Aug 29, 2019 at 1:45

1 Answer 1


Turns out, it uses a connection pool by HikariCP. The default behavior of the maxLifetime and idleTimeout configurations are causing the reconnection. Setting both configurations to 0 disables them and removes the reconnecting issue.

Shoutout to this comment for helping me understand my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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