Report #61734
[bug\_fix] FATAL: could not create shared memory segment: Cannot allocate memory \(Linux shmmax too low\)
Increase the kernel parameter \`kernel.shmmax\` \(and \`kernel.shmall\`\) to at least the size of \`shared\_buffers\`, or reduce \`shared\_buffers\` to fit within current kernel limits.
Journey Context:
Attempting to start a PostgreSQL 15 instance on a Linux server with 64GB RAM. Configuration set \`shared\_buffers = 32GB\`. On startup, PostgreSQL fails immediately with 'FATAL: could not create shared memory segment: Cannot allocate memory'. Checking \`dmesg\` and \`strace\` showed \`shmget\` syscall failing with ENOMEM. Investigation revealed that the Linux kernel parameter \`kernel.shmmax\` \(maximum size of a single shared memory segment\) was set to the default 32MB, far below the requested 32GB. Similarly, \`kernel.shmall\` \(total shared memory pages system-wide\) was too low. The fix required editing \`/etc/sysctl.conf\` to set \`kernel.shmmax = 34359738368\` \(32GB\) and \`kernel.shmall = 8388608\` \(calculated based on page size\), then running \`sysctl -p\`. After applying these kernel parameters, PostgreSQL started successfully. Alternatively, if kernel changes are not permitted, reducing \`shared\_buffers\` to fit within existing \`shmmax\` \(e.g., 16MB\) would allow startup, though with reduced performance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:06:42.133157+00:00— report_created — created