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

时间:2018-06-20 11:22:36

标签: node.js postgresql pg

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

 connection error error: sorry, too many clients already.

PostgresSQL连接配置

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

由于上述错误,我无法查询数据库。我无法解决此问题。能请您提出解决方案

2 个答案:

答案 0 :(得分:2)

以下查询将为您提供帮助。

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

答案 1 :(得分:0)

我遇到了同样的问题,“对不起,已经有太多客户。请求超时”。 我设法解决了。 您可以尝试一些方法

1)第一个可以增加最大连接数和诸如

的其他设置
  { 
    max: 95,    //maximum connection which postgresql or mysql can intiate
    min: 0,     //maximum connection which postgresql or mysql can intiate
    acquire:20000, // time require to reconnect 
    idle: 20000, // get idle connection
    evict:10000 // it actualy removes the idle connection
   }

2)。第二种方法是使用timescaledb,因为有时在复杂查询中,我们会为timescale数据设置超时错误,因此可以设置timescaledb以便运行复杂的数据库查询。 您还可以根据服务器要求为postgres设置最大客户端数。

  

https://github.com/timescale/timescaledb-tune

相关问题