Database: "Error: too many connections for database "postgres""
Last edited: 8/12/2026
当你遇到连接过载的错误 Error: too many connections for database "postgres" 时
🌐 When getting an error where your connections are overwhelmed Error: too many connections for database "postgres"
为什么会发生这个 #
🌐 Why this occurs
当 datconnlimit 被修改时会发生此问题。datconnlimit 的默认值是 -1。
https://www.postgresql.org/docs/current/catalog-pg-database.html
🌐 This issue occurs when datconnlimit gets modified. The default value for datconnlimit is -1.
https://www.postgresql.org/docs/current/catalog-pg-database.html
检查并解决 #
🌐 To check and resolve
-
用下面的查询检查
datconnlimit的值1select datconnlimit from pg_database where datname='postgres';- 如果你看到的值是0或其他任何不是-1的值,就继续下一步。
-
将
datconnlimit更新为默认值1ALTER DATABASE postgres CONNECTION LIMIT DEFAULT;