Psql: FATAL: too many connections for the role

I tried to connect to the database server using the command:

psql -h host_ip -d db_name -U user_name --password

It displays the next line and refuses to connect.

psql: FATAL:  too many connections for role "user_name".

How to close active connections?
I do not have administrator privileges for the database. I am just an ordinary user.

+5
source share
2 answers

From inside any cluster database:

Catch 22: You must first connect to the database. Maybe you can connect as a different user?

To get detailed information about each connection of this user:

SELECT *
FROM   pg_stat_activity
WHERE  usename = 'user_name';

, () :

SELECT pg_cancel_backend(pid)     -- (SIGINT)
    -- pg_terminate_backend(pid)  -- the less patient alternative (SIGTERM)
FROM   pg_stat_activity
WHERE  usename = 'user_name'
AND    pid <> pg_backend_pid();

, . .

pg_cancel_backend() pg_terminate_backend() .

Linux

? , w370? ( , ).

ps, :

ps -aux
ps -aux | grep psql

( , ):

kill  12457689 # pid of process here.

SIGKILL SIGTERM:

kill -9 12457689
+11

postgresql :

ALTER ROLE your_username CONNECTION LIMIT -1;
0

All Articles