Postgres on a VM died overnight; `dmesg` shows "Out of memory: Killed process 2314 (postgres) total-vm:..., anon-rss:...".
IntermediateTroubleshootingDisk, memory and CPU
Answer
Likely causes → The kernel OOM killer picked Postgres because it was the biggest process when the box ran out of memory. Usual triggers: work_mem too high multiplied by many concurrent sorts, another process (a backup, a monitoring agent) eating RAM on the same VM, or no swap headroom.
Diagnose →
dmesg -T | grep -iE 'out of memory|killed process'
journalctl -k --since "-12h" | grep -i oom
grep -E 'shared_buffers|work_mem|max_connections' /etc/postgresql/*/main/postgresql.conf
Correlate the timestamp with cron jobs and the connection count.
Fix → Restart Postgres and check recovery finished cleanly. Lower work_mem or max_connections (put PgBouncer in front), and move the co-located memory hog elsewhere.
Prevent → Set vm.overcommit_memory=2 as the Postgres docs recommend for dedicated DB hosts, protect the postmaster with OOMScoreAdjust=-1000 in its systemd unit, and alert on available memory below 10%.
More on Disk, memory and CPU
The app fails to write with "No space left on device", but `df -h` shows the volume is only 40% used.Beginner`df -h` says `/` is 100% full, but `du -sh /*` only adds up to 30% of the disk.BeginnerA server shows load average 40 on 8 cores, but `top` shows CPU 60% idle and the app is crawling.BeginnerPods are being evicted with "The node was low on resource: ephemeral-storage. Container app was using 18Gi, which exceeds its request of 0."IntermediateCI build agents running Docker fail with "no space left on device" while pulling images; `/var/lib/docker` is 95% full.IntermediateA Java pod keeps getting OOMKilled at its 2Gi limit, even though `-Xmx2g` is set and the heap graph never reaches 2 GB.Intermediate