SQLSTATE 55006 ERROR Class 55: Object Not In Prerequisite State

object_in_use database “…” is being accessed by other users — 55006

PostgreSQL error “database … is being accessed by other users — 55006” (SQLSTATE 55006): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

A DROP DATABASE failed because other sessions are still connected to that database. PostgreSQL raises SQLSTATE 55006 (object_in_use).

  • Other users are connected to the target database.
  • A database with active sessions can’t be dropped.
  • Common when an app pool still holds connections.

What the server log shows

ERROR:  database "appdb" is being accessed by other users
DETAIL:  There are 4 other sessions using the database.

Why PostgreSQL raises this — what the manual says

the DROP DATABASE reference (Description):

“Also, if anyone else is connected to the target database, this command will fail unless you use the FORCE option described below.”

A database in use by active sessions is “in use” and cannot be removed safely. PostgreSQL blocks the drop with 55006 until those sessions disconnect (or are terminated).

Common causes

  • Application connection pools still attached to the database.
  • Idle sessions left open.
  • Monitoring/admin tools connected to it.

How to fix it

  1. Terminate connections, then drop: DROP DATABASE appdb WITH (FORCE); (PG13+).
  2. Manually terminate sessions via pg_terminate_backend() filtered by datname.
  3. Stop the application/pool before dropping the database.

Diagnostic query

SELECT pid, usename, application_name, state FROM pg_stat_activity WHERE datname = 'appdb';

Identify and stop the listed sessions before dropping (or use WITH FORCE).

Related & next steps

Reference: PostgreSQL 18 — DROP DATABASE.

Was this helpful?