57P04
PostgreSQLFATALCommonOperator InterventionHIGH confidence

database dropped

Production Risk

Critical: the database and all its data are permanently deleted.

What this means

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.

Why it happens
  1. 1A DBA ran DROP DATABASE on the database the current session is connected to
  2. 2DROP DATABASE WITH (FORCE) was used in Postgres 13+ to forcibly terminate active connections
How to reproduce

Database dropped while session is active.

trigger — this will error
trigger — this will error
-- 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.

What not to do

Run DROP DATABASE in production without explicit confirmation

DROP DATABASE is irreversible without a backup.

Version notes
Postgres 13+

DROP DATABASE WITH (FORCE) added in Postgres 13.

Sources
Official documentation ↗

Class 57 — Operator Intervention (Postgres-specific)

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors