Django ORM leaves idle connections on Postgres DB
问题 Recently, my Django app has been crashing frequently due to database connection errors: OperationalError: FATAL: sorry, too many clients already When I go into the app database, I see that indeed there are nearly 100 open connections, all with the same query (executed by the Django ORM) and all in the idle state. I have been manually doing SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE state = 'idle'; but I am perplexed as to why this is happening. Can anyone shed any insight