1037
MySQLERRORCriticalServerHIGH confidence

Out of memory — restart server and try again

Production Risk

Critical — server cannot process queries; may require restart.

What this means

ER_OUTOFMEMORY (1037, SQLSTATE HY001) is raised when MySQL cannot allocate memory for an operation. This can be caused by insufficient RAM, excessively large per-session buffers, or a memory leak.

Why it happens
  1. 1Server is under memory pressure due to many concurrent connections
  2. 2Per-session buffers (sort_buffer_size, join_buffer_size) are set too large
  3. 3A single query requires more memory than available (e.g., very large IN list or BLOB handling)
How to reproduce
trigger — this will error
trigger — this will error
-- No single trigger SQL; occurs when memory allocation fails

expected output

ERROR 1037 (HY001): Out of memory; restart server and try again (needed 1234567 bytes)

Fix

Reduce per-session buffer sizes

WHEN Many concurrent connections are exhausting memory.

Reduce per-session buffer sizes
SET GLOBAL sort_buffer_size = 262144;    -- 256 KB
SET GLOBAL join_buffer_size = 262144;    -- 256 KB
SET GLOBAL read_buffer_size = 131072;   -- 128 KB

Why this works

Per-session buffers are allocated for each connection; reducing them allows more concurrent connections within the same RAM budget.

What not to do

✕ Restart the server without investigating the cause

Restarting relieves the symptom but does not fix the underlying over-allocation; the error will recur under the same load.

Sources
Official documentation ↗

MySQL 8.0 — 1037 ER_OUTOFMEMORY

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

← All MySQL errors