
[Solved] PostgreSQL ERROR: There is 1 other session using the database.
- Last Updated on: August 25, 2022
- By: scriptcrunch
In PostgreSQL, if you have active connection to the database and if you try to DROP the database, you will get the following error.
ERROR: database "catalog" is being accessed by other users
DETAIL: There is 1 other session using the database.
To rectify this error and to drop the database, follow the steps given below.
Step 1: First, you need to close all the active connections from programs or tools like PGAdmin. Quit all the applications connecting to the database.
Step 2: Execute the following query from on PostgreSQL to terminate all active connections. Replace catalog
with your database name.
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'catalog';
You will get the following output.
pg_terminate_backend
----------------------
t
(1 row)
Step 3: Delete the database using the DROP command.
DROP DATABASE dvdrental;
Other Interesting Blogs

CKA Exam Study Guide: Certified Kubernetes Administrator
Passing the cloud-native Certified Kubernetes Administrator (CKA) exam is not a cakewalk. To pass the CKA exam, you should have enough hands-on

Linux Foundation Coupon for 2023
Hi Techies, I wanted to let you know about a pretty sweet deal with the Linux Foundation Coupon that is running now.

[35% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux
1 thought on “[Solved] PostgreSQL ERROR: There is 1 other session using the database.”
thank you so much for this, been struggling to delete a database that was being used even if I disconnected from it.