Forums

postgres too many clients already

Please I need to restart my Postgres server ASAP. It keeps throwing FATAL: sorry, too many clients already. It's urgent, please.

Sorry we missed this post this morning. We have restarted your postgres database for you.

Please I need to restart my Postgres server ASAP. It keeps throwing FATAL: sorry, too many clients already. It's urgent, please. We are trying to find which connections are not closing properly. In the meantime, we will like to increase the number of connections but right now we can't even access the postgres console. Please assist.

It was done for you earlier today (see the email).

We have increased the number of connections on but it seems like the Postgres server has not been restarted since then. Please do assist and perform the restart as we having the same issue right now.

Is it possible that you have a bug in your code? Do you have any loops running that are opening connections but not closing them?

We have checked and found nothing, we have some atomic transactions running with django select_for_update to lock certain rows, we are suspecting the issue might be coming from there. Please if you do have any suggestions or guides that might help us debug the issue we will appreciate the help.

We have given all the generic help that we can. In the end, it's up to you to understand how your code works.

+1 to Glenn. Did this start suddenly or just out of the blue? If it started suddenly (I don't know what your web app is doing), could it be that a user accessed a sparsely used feature? That might help you narrow it down.

I don't know what your code is or your app is, so I can't really help you (sorry). Sounds like a bug to me as in connections are not being closed. Its my understanding that the maximum number of connections on a default Postgres server is 115 (15 reserved for the superuser). All I can really say to help is to go through and see what parts of your code could be doing that many transactions (100+) and start there to find the bug.

P.S. if you have other apps running using that server, you can limit the connections on a per user basis to prevent other apps being affected by bugs. Haven't done it, but I did front this on Stack Overflow.

Good luck!

Thanks Glenn for the restart. @tylerhand thanks for the advice, our server was initial at a max connection of 20 but I have bumped that up to 500, while we try to figure out if there are any DB connections not closing.