Out Of Memory — SQLSTATE 53200
SQLSTATE 53200 condition out_of_memory class 53 — Insufficient Resources severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 29 May 2025 · Reproduced live with the SQL on this page.
! Symptoms Free
The server could not allocate memory for the operation.
- The error is written to the server log and returned to the client carrying
SQLSTATE 53200. - Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.
- PL/pgSQL can trap it by name:
EXCEPTION WHEN out_of_memory THEN.
1 Environment & reproduce Free
Severity: ERROR | PostgreSQL versions: 12, 13, 14, 15, 16, 17
Most often seen under load or on under-provisioned servers; correlate it with system metrics (CPU, memory, disk, connection count) at the time of the error.
? Root cause Free
A backend requested more memory than the OS would give — often during large sorts/hashes or with many concurrent connections.
Common causes:
work_memtoo high multiplied across many nodes and connections.- A very large hash or sort.
- A memory leak in an extension.
- OS overcommit limits or too many backends.
3 Recovery & verify Free
Steps to resolve 53200:
- Lower
work_memandmaintenance_work_mem— rememberwork_memis per sort/hash node per query. - Reduce concurrent connections with pooling.
- Inspect the failing plan for huge in-memory operations; add indexes or rewrite.
- Check OS
vm.overcommit, RAM/swap, and the system log for the OOM killer.
Reference: PostgreSQL error codes — Class 53 (Insufficient Resources).