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
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