PG
PRO
57P04FATALTier 1 — Safe✅ HIGH confidence

database dropped

Category: Operator InterventionVersions: All Postgres versions

🔴 Production Risk Error

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
-- From another session:
DROP DATABASE myapp WITH (FORCE);
FATAL: terminating connection due to administrator command

Fix 1: Reconnect to a different database

If the database drop was intentional.

fix

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

If DROP DATABASE was run by mistake.

fix

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

Why it's wrong: DROP DATABASE is irreversible without a backup.

Version notes

Postgres 13+DROP DATABASE WITH (FORCE) added in Postgres 13.

Dangerous variant

⚠️ Warning

57P04 from an accidental DROP DATABASE — data loss

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class 57 — Operator Intervention (Postgres-specific)

Confidence assessment

✅ HIGH confidence

Postgres-specific. Stable across versions.

See also

📄 Reference pages

DROP DATABASEBackupspg_restore
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →