# Matar todas las conexiones a una base de datos Postgres para hacerle DROP Nada, me pasó que tenía que hacer un `drop database` en Postgres y me tiró el siguiente error: ERROR: database "****" is being accessed by other users DETALLE: There is 1 other session using the database. SQL state: 55006 Detail: There is 1 other session using the database. Por lo que tuve que buscar una forma de desconectar a los clientes conectados, por suerte en [stack overflow](https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-connections-to-it) encontré la respuesta. Así que robando descaradamente: ## PostgreSQL 9.2 and above: SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' -- ← change this to your DB AND pid <> pg_backend_pid(); ## PostgreSQL 9.1 and below: SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' -- ← change this to your DB AND procpid <> pg_backend_pid();