Skip to content

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

  1. 用下面的查询检查 datconnlimit 的值

    1
    select datconnlimit from pg_database where datname='postgres';
    • 如果你看到的值是0或其他任何不是-1的值,就继续下一步。
  2. datconnlimit 更新为默认值

    1
    ALTER DATABASE postgres CONNECTION LIMIT DEFAULT;