Kubernetes Container Exit Codes Decoded
Every crash loop leaves a number behind. Learn to read exit codes straight from kubectl describe and know the fix before you open the logs.
Key takeaways
- A Kubernetes exit code is the integer a container returned when it stopped, shown under Last State in kubectl describe pod.
- Codes above 128 mean a signal killed it, so 137 is SIGKILL, usually OOMKilled, and 143 is SIGTERM from a normal shutdown.
- 1 is an app error, 126 and 127 are entrypoint problems.
On this page
A Kubernetes exit code is the number a container returned when it stopped, shown under Last State in kubectl describe pod. Above 128, a signal killed it (subtract 128 for the signal): 137 is SIGKILL, usually OOMKilled; 143 is SIGTERM from a normal shutdown. 1 is an app error; 126 and 127 are entrypoint problems.
Verified against
Kubernetes 1.37 (1.37.1), against the kubernetes.io Pod lifecycle docs, the signal(7) man page and the Docker run reference for exit statuses. Checked October 2026.
The exit code is honest. Logs can be swallowed by a buffer that never flushed, and metrics lag. The exit code is recorded the instant the process ends, and it sits in the pod status waiting for you. Learn to read it and you can triage half your incidents in about ten seconds.
Where the number lives
You read it off the pod, not the logs:
kubectl describe pod api-7d9f8c6b4-xk2vq
Scroll to the container block and look at Last State. A service dying of memory pressure looks like this:
Containers:
api:
Container ID: containerd://8f3e...
Image: registry.internal/api:1.42.0
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
Started: Wed, 08 Jul 2026 03:14:02 +0000
Finished: Wed, 08 Jul 2026 03:14:19 +0000
Ready: False
Restart Count: 6
State: Waiting with Reason: CrashLoopBackOff tells you the container is stuck restarting; the kubelet backs off 10s, 20s, 40s and so on, capped at 5 minutes. Last State: Terminated tells you why the last attempt died. The Exit Code and Reason are the payload. For just the number:
kubectl get pod api-7d9f8c6b4-xk2vq \
-o jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}'
The reference table
| Exit | Meaning | First thing to check |
|---|---|---|
| 0 | Clean exit | Job done, or a service that shouldn't have stopped |
| 1 | General application error | App logs, unhandled exception |
| 125 | Runtime could not start the container | Image, runtime (a docker run code; rare in Kubernetes) |
| 126 | Command found but not executable | File mode, entrypoint bit |
| 127 | Command not found | Typo in command, missing binary |
| 130 | 128 + 2, SIGINT | Ctrl-C, interrupt |
| 137 | 128 + 9, SIGKILL | OOMKilled, or SIGTERM ignored past the grace period |
| 139 | 128 + 11, SIGSEGV | Segfault, native memory bug |
| 143 | 128 + 15, SIGTERM | Shutdown, graceful or not |
How signals become numbers
Everything from 129 up follows a Unix shell convention: when a process is killed by a signal, the exit status is 128 + signal number. SIGKILL is signal 9, giving 137. SIGTERM is 15, giving 143. SIGSEGV is 11, giving 139. Subtract 128 and look up the signal in signal(7).
This is why 137 and 143 are the two you will see most. Kubernetes runs on signals. When it wants a container gone politely, it sends SIGTERM (143). When politeness runs out, it sends SIGKILL (137).
The codes worth knowing cold
0, clean exit. The process finished with no error. For a Job or an init container, this is what you want. For a long-running service, a 0 is suspicious: something told your main process to stop and it obliged. Check whether a script is exiting early or a supervisor inside the container is quitting.
1, general application error. The catch-all. Your code threw and nothing caught it, a config file was missing, a required env var was unset. The exit code gives you nothing more here; this is the one case where you go straight to kubectl logs --previous.
125, the runtime failed. Docker's reference defines 125 as an error in the daemon itself, not your app. Under Kubernetes the same class of failure (wrong architecture, a corrupt layer, a bad mount) more often surfaces as CreateContainerError or RunContainerError before any exit code exists. Check the image reference and the node's runtime before you blame your code.
126, permission or not executable. The binary is there but cannot be invoked. Usually the entrypoint script lost its executable bit somewhere in the build. A chmod +x in the Dockerfile (or COPY --chmod=755) fixes most of these.
127, command not found. The most common self-inflicted wound. Your entrypoint points at a binary that is not on the PATH, you have a typo, or you built a slim base image that dropped bash. Plenty of containers have shipped expecting /bin/bash on Alpine, which only has sh.
137, SIGKILL, almost always OOMKilled. The container exceeded its memory limit and the kernel's OOM killer put it down hard. The giveaway is Reason: OOMKilled right above the exit code. Raise the limit or fix the leak; the full triage is in fixing OOMKilled. The other, rarer 137 is a SIGKILL that landed because a container ignored SIGTERM and the grace period ran out. If the node itself is short on memory, the pod may instead be evicted, which fixing evicted pods covers.
139, segfault. SIGSEGV, signal 11. The process touched memory it had no business touching. In pure Go or Java this is rare; when you see it, suspect a native library, a CGO boundary, or a corrupt binary. This is a real bug, not a config problem, and it needs a debugger or a core dump.
143, SIGTERM. The most misread code on this list. 143 means the container received SIGTERM, which is exactly what Kubernetes sends during every normal shutdown, scale-down, and rolling deploy. On its own, 143 is often fine. It only means trouble when it pairs with CrashLoopBackOff, which tells you the container is being stopped repeatedly without you asking.
130, SIGINT. Signal 2, the Ctrl-C code. Kubernetes itself rarely produces it; it shows up when someone attaches to a container and interrupts it, or when a shell wrapper forwards an interrupt.
Graceful termination, and why 143 confuses people
When Kubernetes removes a pod, it does not just yank it. The kubelet asks the runtime to send SIGTERM (or the image's STOPSIGNAL) to the main process, then waits terminationGracePeriodSeconds, 30 seconds by default. Only when that expires does it send SIGKILL to whatever is still running.
A well-behaved app catches SIGTERM, drains connections, flushes state, and exits within the grace window. A badly behaved app ignores SIGTERM, sits there until 30 seconds elapse, and then gets a 137. That slow, ugly shutdown shows up as latency during every deploy. If your rollouts feel sticky, check whether PID 1 actually handles SIGTERM; a shell-form ENTRYPOINT often swallows it.
The other trap is the liveness probe. When a container fails its liveness probe more times than the threshold allows, the kubelet restarts it through the same SIGTERM-then-SIGKILL path, and you see a signal-based code. If a container keeps dying with 143 or 137 and you never asked it to stop, look at your probe thresholds before your code. An aggressive liveness probe on a service that is merely slow to warm up will kill it in a loop; a startup probe is the fix. Our Kubernetes troubleshooting guide covers the probe traps in depth.
Questions people ask
What does exit code 137 mean in Kubernetes?
Exit code 137 is 128 plus 9, meaning the container was killed with SIGKILL. In most cases Reason: OOMKilled appears next to it, which means the container exceeded its memory limit and the kernel's OOM killer stopped it. Without that reason, the container probably ignored SIGTERM and was force-killed when terminationGracePeriodSeconds, 30 seconds by default, expired. Raise the limit, fix the leak, or handle SIGTERM.
Is exit code 143 an error?
Usually not. Exit code 143 is 128 plus 15, meaning the process received SIGTERM, which Kubernetes sends on every deploy, scale-down, and pod deletion. A service that exits 143 during a rollout shut down as asked. It becomes a problem only alongside CrashLoopBackOff or repeated restarts you didn't trigger, which usually points at a failing liveness probe killing the container.
How do I find the exit code of a crashed pod?
Run kubectl describe pod <name> and read Exit Code and Reason under Last State: Terminated in the container block. For scripts, use kubectl get pod <name> -o jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}'. Then run kubectl logs <name> --previous to see the output of the attempt that died, since the current container may have already restarted.
The call we'd make
Read the exit code first, every time. Treat 137 as memory until proven otherwise, treat 127 and 126 as build problems, and never panic at a lone 143. The number is not the whole diagnosis, but it points you at the right half of the haystack before you have read a single log line. It is the fastest triage tool Kubernetes gives you for free, so use it.
Sources
Cite this article
Kiril Urbonas (2026). Kubernetes Container Exit Codes Decoded. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/kubernetes-exit-codes
[Kubernetes Container Exit Codes Decoded](https://www.devopsness.com/blog/kubernetes-exit-codes) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
Infrastructure Monitoring with Prometheus: Complete Setup Guide
A working Prometheus stack for a 40-node cluster: what we deploy, what we tune, and what we wish we'd known about cardinality two years ago.
Azure DevOps Best Practices in 2026: Build Pipelines You Can Trust
A production-focused, example-rich guide to Azure DevOps: template-driven YAML, immutable artifact promotion, secure OIDC service connections, environment approvals, canary rollouts with automatic rollback, IaC governance, and DORA-driven delivery reliability.
Istio vs Linkerd: Service Mesh Comparison (2026)
A practitioner-grade breakdown of Istio and Linkerd across architecture, mTLS, traffic control, performance, and total cost of ownership.
You might have missed
Evergreen posts worth revisiting.