Error: sorry, too many clients already

2019-08-23 19:55发布

I am using PostgreSQL in my NodeJS backend service. All of sudden, when I start the service I am facing below error

 connection error error: sorry, too many clients already.

PostgresSQL connection config

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

I am unable to query database because of the above error. I am unable to fix this issue. Can you please suggest the solution

1条回答
神经病院院长
2楼-- · 2019-08-23 20:26

below query will help you.

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
查看更多
登录 后发表回答