database dropped
Production Risk
Critical: the database and all its data are permanently deleted.
SQLSTATE 57P04 is raised when the database a session is connected to is dropped while the session is active. Postgres terminates all connections to the dropped database.
- 1A DBA ran DROP DATABASE on the database the current session is connected to
- 2DROP DATABASE WITH (FORCE) was used in Postgres 13+ to forcibly terminate active connections
Database dropped while session is active.
-- From another session: DROP DATABASE myapp WITH (FORCE);
expected output
FATAL: terminating connection due to administrator command
Fix 1
Reconnect to a different database
WHEN If the database drop was intentional.
Why this works
The dropped database no longer exists. Connect to a different database or create a new one.
Fix 2
Restore from backup if the drop was accidental
WHEN If DROP DATABASE was run by mistake.
Why this works
Restore from the most recent backup (pg_dump or pg_basebackup). There is no undo for DROP DATABASE — backups are essential.
✕ Run DROP DATABASE in production without explicit confirmation
DROP DATABASE is irreversible without a backup.
DROP DATABASE WITH (FORCE) added in Postgres 13.
Class 57 — Operator Intervention (Postgres-specific)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev