Download

cannot drop the currently open database

You ran DROP DATABASE while connected to that same database, and a session can’t remove the database it’s using. Connect to another database on the same server (postgres is always there) and drop it from there, or use dropdb, which does that for you.

PostgreSQL error 55006· Tested on PostgreSQL 18.6· Updated 11 October 2026

ERROR:  cannot drop the currently open database

What it means

Every PostgreSQL session is connected to exactly one database and can’t switch to another. A database can only be dropped when no session is using it, and that includes yours, so PostgreSQL refuses straight away:

ERROR:  cannot drop the currently open database

Nothing was changed. The fix is to run the same command from a session connected to some other database on the same server.

Common causes

  1. Dropping from inside it: you connected to shop to look around, then ran DROP DATABASE shop in the same window.
  2. A client or script whose connection names the database it’s dropping, such as a reset script using the app’s own DATABASE_URL.
  3. A test or setup tool configured with the test database as its maintenance database.

How to fix it

Connect to another database, then drop

Every server has a database called postgres, made for this kind of maintenance:

psql -h <host> -U <user> -d postgres -c 'DROP DATABASE shop'

In psql you can switch first with \c postgres (which opens a new session in postgres), then run DROP DATABASE shop;. Any other database you can connect to works as well.

Or use dropdb

dropdb connects to a maintenance database for you (postgres, or template1 if that fails):

dropdb -h <host> -U <user> shop
dropdb -h <host> -U <user> --force shop   # PostgreSQL 13+: also ends other sessions

If it then says other users are connected

Once you’re not the one using it, other sessions may still be: see database is being accessed by other users.

Not inside a transaction

DROP DATABASE can’t run inside BEGIN … COMMIT either; some tools wrap everything in a transaction, and then the error is DROP DATABASE cannot run inside a transaction block.

Reproduce it

In a throwaway PostgreSQL 18.6 container, connected to a database named shop:

DROP DATABASE shop;
SELECT current_database();
ERROR:  cannot drop the currently open database
 current_database
------------------
 shop
(1 row)

From a session connected to postgres, DROP DATABASE IF EXISTS shop then worked. With \set VERBOSITY verbose, psql shows the code: ERROR: 55006: cannot drop the currently open database.

In Inlet

On connections Inlet protects, a DROP in the query editor asks before it runs and says why. Run the DROP DATABASE from a connection whose database is a different one, such as postgres; when a statement fails, Inlet shows the server’s error, and What this error means opens this page.

Inlet: a database client for the Mac

One native app for PostgreSQL, MySQL, SQL Server, SQLite, MongoDB and Redis. It explains errors where they happen, holds your edits until you save them, and keeps production read-only until you say so.

Version 0.1.0 · macOS 26 Tahoe or later · Apple silicon and Intel