错误:抱歉,已经有太多客户

Hem*_*ari 3 postgresql node.js pg

我在 NodeJS 后端服务中使用 PostgreSQL。突然之间,当我启动服务时,我面临以下错误

 connection error error: sorry, too many clients already.
Run Code Online (Sandbox Code Playgroud)

PostgresSQL 连接配置

 const pg = require(“pg”);
 const client = new pg.Client({
        host: “txslmxxxda6z”,
        user: “mom”,
        password: “mom”,
        db: “mom”,
        port: 5025
 });
Run Code Online (Sandbox Code Playgroud)

由于上述错误,我无法查询数据库。我无法解决这个问题。你能提出解决方案吗

Paw*_*rma 5

下面的查询会帮助你。

select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal 
from 
  (select count(*) used from pg_stat_activity) t1,
  (select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2,
  (select setting::int max_conn from pg_settings where name=$$max_connections$$) t3
Run Code Online (Sandbox Code Playgroud)