Connect to your PostgreSQL database using the psql command-line tool. For example
1- psql -U your_username -d your_database_name
2- SELECT pg_terminate_backend(PID);
Replace PID with the process ID of the connection you want to terminate. You can find the process IDs of active connections by running the following query:
3- SELECT pid, datname, usename, application_name FROM pg_stat_activity;
For instance, if you want to terminate connections with PIDs 1234, 5678, and 9101, the query would look like this:
4- SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE pid IN (1234, 5678, 9101);