# MongoDB: Out of memory: Killed process (mongod) — WiredTiger cache + queries exhausted RAM

**Code:** `mongod killed by OOM killer` · **Category:** MongoDB · **Seen on:** MongoDB, Linux

The Linux OOM killer terminated `mongod` because the host ran out of memory.

## Meaning

Check `dmesg | grep -i "killed process"`. Limit the WiredTiger cache (`storage.wiredTiger.engineConfig.cacheSizeGB`), especially in containers where MongoDB reads host RAM instead of the cgroup limit (older versions). Avoid huge in-memory sorts/aggregations, add indexes, and size the host properly with swap off for DBs but enough RAM.

## Common causes

- Container memory limit smaller than WiredTiger default cache
- Large aggregations without indexes (allowDiskUse needed)
- Other processes sharing the host
- Too many connections (each uses memory)
- Undersized instance

## Quick fix

1. Set `cacheSizeGB` to ~50% of available RAM (or lower in containers)
2. Add indexes; use `allowDiskUse: true`
3. Move to a larger instance or isolate mongod

## Detailed fix by platform

### Linux

1. `dmesg -T | grep -i -E "killed process|out of memory"; free -h`

## How to diagnose

1. **dmesg** — OOM entry?
2. **Cache** — Configured?
3. **Queries** — Heavy aggregations?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mongodb/oom-killed-mongod)
