Skip to main content
How to Fix OOMKilled (Exit Code 137) in Kubernetes

How to Fix OOMKilled (Exit Code 137) in Kubernetes

KU
· Founder & Chief Editor
• 8 min read•Updated •

A pod dies, restarts, dies again, and the events say OOMKilled. Here is what exit code 137 actually means and how to stop the loop for good.

Key takeaways

  • OOMKilled with exit code 137 means the kernel killed a container with SIGKILL after it exceeded its memory limit.
  • Confirm it with kubectl describe pod, compare kubectl top against the limit, then either raise the limit with headroom or fix a leak.
  • Set requests on every pod and cap runtime heaps below the limit.

OOMKilled (exit code 137) means the container used more memory than its limits.memory and the kernel killed it with SIGKILL. Confirm it in the Last State block of kubectl describe pod, compare kubectl top pod to the limit, then raise the limit with headroom if usage is flat, or find the leak if usage only climbs.

Verified against

Kubernetes 1.37 (latest stable v1.37.2), against the kubernetes.io resource management, Pod QoS, assign-memory-resources and Vertical Pod Autoscaler docs. Checked October 2026.

The symptom is always the same shape: a pod restarts on a rhythm, logs cut off mid-request, CPU looks fine, and there is no stack trace or panic. That is the signature of 137, and once you know what it is saying, the fix is usually mechanical.

What OOMKilled and 137 actually mean

A container has a memory limit. When the process inside tries to use more than that limit, the Linux kernel's OOM (out of memory) killer steps in and sends the process a SIGKILL. SIGKILL is signal 9. When a process is terminated by a signal, its exit code is 128 + signal number, so 128 + 9 = 137. That is the whole story behind the number, and Kubernetes exit codes decoded covers its neighbors (1, 139, 143).

Kubernetes reads the exit code and the cgroup memory event, then labels the container OOMKilled. The container did not crash on its own; the kernel shot it because it crossed the line you drew in the pod spec. SIGKILL cannot be caught or handled, which is why you get no graceful shutdown and no last log line.

There are two flavors worth separating early. A pod-level OOM means one container blew past its own limit, and only that container dies. A node-level OOM means the whole node ran out of physical memory and the kernel starts killing processes to survive, which can take down pods that were behaving fine. They look similar in kubectl but the fix is different.

Diagnosis: prove it before you touch anything

Start with describe. The Last State block is where the truth lives:

Terminal
kubectl describe pod payments-worker-7f9c8 | grep -A5 "Last State"
code
Last State:     Terminated
  Reason:       OOMKilled
  Exit Code:    137
  Started:      Thu, 09 Jul 2026 09:14:02
  Finished:     Thu, 09 Jul 2026 09:18:31

Now check actual usage against the limit. Metrics Server has to be installed for this:

Terminal
kubectl top pod payments-worker-7f9c8 --containers

If the worker sits at 480Mi against a 512Mi limit all day, you have your answer without any deep forensics. For a leak, watch it climb over time instead of reading a single snapshot. A quick loop or a Grafana panel on container_memory_working_set_bytes tells you whether memory grows and never comes back down, or whether it just spikes under load.

To tell pod OOM from node OOM, look at the node:

Terminal
kubectl describe node ip-10-0-3-14 | grep -A3 "MemoryPressure"
# on the node itself:
dmesg -T | grep -i "oom-kill"

If the node reports MemoryPressure: True and dmesg shows the kernel killing processes across several pods, you are dealing with a node that is oversubscribed, not a single greedy container. That case usually surfaces as evictions rather than OOMKilled, which fixing evicted pods and node pressure walks through.

Requests, limits, and why QoS matters here

This is the part people skip, and it is the part that decides who dies first. A request is what the scheduler reserves for your pod when placing it on a node. A limit is the hard ceiling the kernel enforces. OOMKilled is always about the limit.

Those two numbers also set your pod's QoS class. Per the Kubernetes docs, when a node runs out of resources it evicts BestEffort pods first, then Burstable, then Guaranteed:

  • Guaranteed: requests equal limits for every container. Last to be evicted under node pressure.
  • Burstable: requests set, limits higher or absent. Evicted only after all BestEffort pods are gone.
  • BestEffort: no requests or limits at all. First against the wall when a node runs out.

If you run BestEffort pods next to important workloads, one noisy neighbor with a memory spike can trigger a node OOM that evicts your good pods. That alone is a reason to always set requests.

Causes and the fix for each

Limit set too low. The most common case. Someone copied a 256Mi limit from a template and the app legitimately needs 700Mi. Right-size it from real usage, not a guess. Look at the peak working set over a representative window and set the limit above the peak with headroom:

YAML
# deployment.yaml (container spec excerpt)
resources:
  requests:
    memory: "512Mi"
  limits:
    memory: "768Mi"

A real leak. If memory only ever climbs and a restart resets it, no limit will save you; you are just buying time between kills. Grab a heap profile (pprof for Go, a heap dump for the JVM, --inspect for Node) and find what is holding references. Raising the limit here is treating a fever with a bigger blanket.

Runtime heap sized for the wrong machine. Older JVM and Node releases read the host's total memory rather than the container limit and sized their heap for a machine that does not exist. Current runtimes are cgroup-aware, but their defaults still leave the heap ceiling implicit. Make it explicit with runtime flags:

code
# Dockerfile or container env: JVM heap as a share of the cgroup limit
JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75.0"
# Node: old-space cap in MiB, roughly 75% of a 512Mi limit
NODE_OPTIONS="--max-old-space-size=384"

Leave headroom between the heap and the container limit for off-heap allocations, thread stacks, and metaspace. A heap sized at the full limit will still get OOMKilled.

Traffic spike. Memory tracks concurrency, and a burst pushes you over a limit that was fine at steady state. Cap in-flight work, add backpressure, and set limits against your realistic peak, not your average.

No limits at all. Feels safe until one pod eats the node and the kernel starts culling neighbors. Always set requests so the scheduler plans correctly, and set limits so a single container cannot take the whole node hostage.

For workloads whose appetite genuinely moves around, the Vertical Pod Autoscaler can recommend and set requests and limits from observed usage instead of leaving it to a stale template. Start with updateMode: "Off", where the recommender still computes values but applies nothing, and read what it suggests before moving to Initial, Recreate, or InPlaceOrRecreate. It is far better than the number someone guessed eighteen months ago. Sizing the requests themselves is its own job, covered in right-sizing resource requests.

If you want the broader map of pod failure states, our Kubernetes troubleshooting guide covers the neighbors of 137: CrashLoopBackOff, ImagePullBackOff, and the rest.

Questions people ask

What does exit code 137 mean in Kubernetes?

Exit code 137 is 128 plus signal 9, so the process was killed with SIGKILL. When the container status also says OOMKilled, the Linux OOM killer did it because the container exceeded its memory limit. Without OOMKilled, 137 can also come from a kill after the termination grace period expires, or from something else sending SIGKILL, so check Reason in kubectl describe pod.

Should I just remove the memory limit to stop OOMKilled?

No. Without a limit the container can grow until the node itself runs out of memory, and then the kernel and kubelet start killing or evicting neighbors that did nothing wrong. A pod with no requests or limits is also BestEffort, the first class evicted under node pressure. Set the limit above observed peak with headroom instead, and fix leaks rather than hiding them.

Why is my Java pod OOMKilled when the heap is smaller than the limit?

The container limit covers the whole process, not just the heap. Metaspace, thread stacks, direct buffers, JIT code cache, and native libraries all count. A heap set close to the limit leaves no room for them. Keep -XX:MaxRAMPercentage around 75 percent or lower, and watch container_memory_working_set_bytes rather than heap metrics to see what the kernel sees.

The call we'd make

Confirm it is really OOMKilled with describe, then look at kubectl top before you change a single value. If usage sits flat near the limit, right-size the limit with headroom and move on. If it climbs forever, stop raising the limit and go find the leak, because a bigger ceiling only changes how often the pager fires. Set requests on everything so QoS works in your favor, teach the JVM and Node their real limit, and reach for VPA when the workload's appetite refuses to hold still.

Sources

Explore topics:KubernetesDevOps
React
Share this post
Cite this article
Plain text

Kiril Urbonas (2026). How to Fix OOMKilled (Exit Code 137) in Kubernetes. DevOpsNess. Updated 2026-11-15. https://www.devopsness.com/blog/fix-oomkilled

Markdown

[How to Fix OOMKilled (Exit Code 137) in Kubernetes](https://www.devopsness.com/blog/fix-oomkilled) (Kiril Urbonas, DevOpsNess, updated 2026-11-15)

KU

Kiril Urbonas

Founder & Chief Editor

608 articles
View all articles by Kiril Urbonas

You might have missed

Evergreen posts worth revisiting.