SQLSTATE 55006 ERROR Class 55: Object Not In Prerequisite State

object_in_use cannot drop the currently open database — 55006

PostgreSQL error "cannot drop the currently open database" (SQLSTATE 55006): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A DROP DATABASE targeted the database the current session is connected to. PostgreSQL refuses with SQLSTATE 55006 (object_in_use).

  • You tried to drop the database you are connected to.
  • A session cannot drop its own database.
  • Must connect elsewhere first.

What the server log shows

ERROR:  cannot drop the currently open database

Why PostgreSQL raises this — what the manual says

the DROP DATABASE reference (Description):

“It cannot be executed while you are connected to the target database.”

A database in use by your own session is “in use” and cannot be removed. PostgreSQL blocks the drop with 55006 until you connect to a different database.

Common causes

  • Issuing DROP DATABASE while connected to that same database.
  • Scripts that don’t switch databases before dropping.

How to fix it

  1. Connect to another database (e.g. postgres), then run DROP DATABASE.
  2. In psql: \c postgres before dropping.
  3. Use DROP DATABASE … WITH (FORCE) (PG13+) from another database to disconnect other users.

Related & next steps

Reference: PostgreSQL 18 — DROP DATABASE.

Was this helpful?