Report #9516
[bug\_fix] ERROR: out of shared memory \(SQLSTATE 53100\)
Reduce PostgreSQL's \`max\_connections\` to fit within the kernel's available shared memory limits \(check \`shmmax\` and \`shmall\` with \`ipcs -l\`\), or increase kernel parameters \(\`sysctl -w kernel.shmmax=\`\) and restart Postgres; additionally, consider lowering \`shared\_buffers\` if it consumes too much of the shared memory segment.
Journey Context:
You are migrating a Postgres instance to a larger cloud VM with more CPU cores. To utilize the cores, you increase \`max\_connections\` from 100 to 500 in postgresql.conf and restart. Postgres fails to start with "could not create shared memory segment: No space left on device" or, if it starts, clients get "ERROR: out of shared memory" when trying to allocate locks. You check \`ipcs -lm\` and see \`max total shared memory \(kbytes\) = 1800000\` \(about 1.8GB\), but Postgres calculates it needs roughly 500 \* \(shared\_buffers overhead \+ lock space\) which exceeds this. You try raising \`max\_connections\` in the kernel via \`sysctl -w kernel.shmmax=8589934592\` \(8GB\), but you don't have sudo or a reboot is required. Instead, you reduce \`max\_connections\` back to 100 and implement PgBouncer to handle the 500 application connections, multiplexing them down to 100 actual Postgres backends. This fits within the shared memory constraints while serving the load. Alternatively, if you had kernel access, increasing shmmax would be the direct fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:20:28.111928+00:00— report_created — created