Report #89013
[bug\_fix] could not create shared memory segment: Cannot allocate memory / FATAL: out of memory for connection
Reduce max\_connections to fit within kernel SHMMAX/SHMALL limits or container memory limits, or increase kernel shared memory parameters. Alternatively, move to connection pooling architecture.
Journey Context:
Deployed PostgreSQL 15 in a Kubernetes container with default max\_connections=100. Pod kept crashing on startup with FATAL: could not create shared memory segment: Cannot allocate memory. Checked dmesg showing OOM kills despite container memory limit being 2GB. Realized each connection allocates shared memory for work\_mem and maintenance\_work\_mem tracks; 100 connections exceeded the container's /dev/shm size \(default 64MB in old K8s versions\). Reduced max\_connections to 20 and configured PgBouncer outside the container to handle the 100\+ actual client connections.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:59:58.836147+00:00— report_created — created