Sample Header Ad - 728x90

psql: FATAL: sorry, too many clients already

37 votes
3 answers
162778 views
I am suddenly getting this error when either trying to access the website that uses the postgresql database, or even when using the psql utility or pgadmin3. My database is set to handle 150 maximum connections: # SHOW max_connections; max_connections ----------------- 150 (1 row) After rebooting the ubuntu server which my website is on (which is really the only thing using connections), I see the current amount of connections is 140: # select count(*) from pg_stat_activity; count ------- 140 (1 row) I don't understand how suddenly so many connections after rebooting my server. So I check the postgresql activity: # SELECT * FROM pg_stat_activity; And I see over a 100 columns with the same exact query that looks like this: SELECT "reports".* FROM "reports" WHERE (("reports"."time" | f | | 2014-06-29 00:05:06.735249-04 | 2014-06-27 16:34:39.307312-04 | 192.111.11.111 | 52759 464875 | mydb | 5054 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.52573-04 | 2014-06-28 22:46:59.52573-04 | 2014-06-28 22:46:52.285867-04 | 192.111.11.111 | 37371 464875 | mydb | 5055 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.530804-04 | 2014-06-28 22:46:59.530804-04 | 2014-06-28 22:46:52.303562-04 | 192.111.11.111 | 37372 464875 | mydb | 5056 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.572198-04 | 2014-06-28 22:46:59.572198-04 | 2014-06-28 22:46:52.31447-04 | 192.111.11.111 | 37373 464875 | mydb | 5057 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.872037-04 | 2014-06-28 22:46:59.872037-04 | 2014-06-28 22:46:52.323721-04 | 192.111.11.111 | 37374 464875 | mydb | 5058 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.961803-04 | 2014-06-28 22:46:59.961803-04 | 2014-06-28 22:46:52.334238-04 | 192.111.11.111 | 37375 464875 | mydb | 5059 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.53713-04 | 2014-06-28 22:46:59.53713-04 | 2014-06-28 22:46:52.347227-04 | 192.111.11.111 | 37376 464875 | mydb | 5060 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:47:00.208948-04 | 2014-06-28 22:47:00.208948-04 | 2014-06-28 22:46:52.360008-04 | 192.111.11.111 | 37377 464875 | mydb | 5061 | 16387 | myuser | SELECT "reports".* FROM "reports" WHERE (("reports"."time" < '2014-06-28 13:30:42.000000' AND "reports"."unit_id" = 3192)) ORDER BY "reports"."id" DESC LIMIT 1 | f | 2014-06-28 22:46:59.938983-04 | 2014-06-28 22:46:59.938983-04 | 2014-06-28 22:46:52.369496-04 | 192.111.11.111 | 37378
Asked by JohnMerlino (1939 rep)
Jun 29, 2014, 04:30 AM
Last activity: Aug 5, 2021, 08:42 AM