postgresql 数据库 报错 FATAL: sorry, too many clients already 解决方法

发布时间 2023-07-28 10:23:07作者: 剑道第一仙

场景

项目 postgres 连接不上, 所有连接报错 :psql: FATAL: sorry, too many clients already

原由
程序使用连接未及时释放, 连接一直处于 idle 状态

处理方式
1、 程序里面未释放的连接, 在使用后及时释放;
2、 postgres 连接数默认最大 100个,在配置文件修改该参数;
postgres.conf max_connection = 1000 修改后重启生效;
3、 postgres 设置 idle 状态连接回收, 该状态默认不开启;
postgres.conf idle_in_transaction_session_timeout=20000; 修改为idle 状态 20s 后回收该连接; 修改后重启

 

转:https://blog.csdn.net/whatday/article/details/128590239