I want to set up a separate connection for every user of my app. I have some data structure for this to store connections. Obviously, I should delete the expired connections somehow. There are multiple ways to do it.

The best one is to make a callback between Postgres and my app when a connection timeout has occurred. So my app will have some function like on_connection_timeout to remove old connections.

But is Postgres have at all such feature to tell about connection timeout?

P.S. If no - I will implenet a FIFO

1 Answer 1


PostgreSQL v14 introduced the parameter idle_session_timeout, which is exactly what you are looking for. Note that the client will get an error if it tries to use a connection that has been closed by the server.

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.