Exit codes 137 and 143: SIGKILL vs SIGTERM in Kubernetes

Reproduced on k3s v1.31.5 (k3d) with kubectl v1.36.1.

What you see

# Four pods, four different stories behind 137 and 143 (containerID removed)
$ kubectl get pod <pod> -n lab -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'

oom-demo      (32Mi limit, memory hog)
{"exitCode":137,"finishedAt":"2026-11-20T01:11:00Z","reason":"OOMKilled","startedAt":"2026-11-20T01:11:00Z"}

pid1-demo     (sleep as PID 1, liveness fails, 10s grace period)
{"exitCode":137,"finishedAt":"2026-11-20T01:11:25Z","reason":"Error","startedAt":"2026-11-20T01:11:10Z"}

kill9-demo    (kill -9 sent to the process from the node)
{"exitCode":137,"finishedAt":"2026-11-20T01:11:45Z","reason":"Error","startedAt":"2026-11-20T01:11:44Z"}

sigterm-demo  (shareProcessNamespace, so sleep is not PID 1, liveness fails)
{"exitCode":143,"finishedAt":"2026-11-20T01:11:00Z","reason":"Error","startedAt":"2026-11-20T01:10:56Z"}

What it means

When a process is ended by a signal, the runtime reports 128 plus the signal number. SIGTERM is 15, so 143. SIGKILL is 9, so 137. The exit code says how the process ended, not who sent the signal or why.

When Kubernetes stops a container, for a delete, rollout, drain or liveness failure, it sends the stop signal (SIGTERM unless the image sets another one). It then waits terminationGracePeriodSeconds, 30 by default. If the process is still alive, it sends SIGKILL. So 143 means the app died on SIGTERM. 137 with reason Error often means it ignored SIGTERM and was killed when the grace period ran out.

PID 1 in a container is special. The kernel does not apply the default action for SIGTERM to PID 1, so a process with no handler simply ignores it. In our lab, sleep as PID 1 waited out the full 10 second grace period and ended as 137. The same sleep as a non-PID 1 process ended as 143 without waiting for the grace period.

Common causes

137 with reason OOMKilled

The kernel killed the process for going over its memory limit. This is the case most people expect.

How to tell: lastState.terminated.reason is OOMKilled. See the OOMKilled page for the fix.

137 after the grace period ran out

Kubernetes sent SIGTERM and the process did not exit in time. Common causes are PID 1 with no signal handler, a shell wrapper that does not pass the signal on or a slow shutdown.

How to tell: Reason Error. finishedAt is about terminationGracePeriodSeconds after a Killing event.

137 from something else sending SIGKILL

A node agent, a script or a person ran kill -9, or the node-level OOM killer picked the process.

How to tell: Reason Error with no Killing event from the kubelet just before it. Check the node's kernel log for OOM lines.

143 from a normal stop

The process received SIGTERM and exited with the default action. Rollouts, scale-downs, drains and liveness failures all do this.

How to tell: A Killing event just before, with the reason. For example failed liveness probe or a rollout.

137 or 143 set by the app itself

A shell or runtime returns 128 plus N when one of its child processes was killed by a signal. The container itself may never have received one.

How to tell: Logs show a child process being killed or a wrapper script exiting with its child's status.

How to diagnose it

  1. kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'

    Read exitCode and reason together. 137 plus OOMKilled is memory. 137 plus Error needs the next steps. Compare startedAt and finishedAt too.

  2. kubectl get events -n <namespace> --field-selector involvedObject.name=<pod> --sort-by=.lastTimestamp

    A Killing event says why the kubelet stopped the container. No Killing event means something else sent the signal.

  3. kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.terminationGracePeriodSeconds}'

    If the time between the Killing event and finishedAt matches this value, the app ignored or outlived SIGTERM.

  4. kubectl debug node/<node> -it --image=busybox:1.36 --profile=sysadmin -- dmesg

    Look for Out of memory or Killed process lines at the time of the exit. These point to a node-level OOM kill.

  5. kubectl exec <pod> -n <namespace> -- cat /proc/1/cmdline

    Shows what runs as PID 1. A shell such as sh -c that starts your app as a child often does not pass SIGTERM on.

How to fix it

Make the app the process that gets SIGTERM

Use the exec form of ENTRYPOINT, or end wrapper scripts with exec so the app replaces the shell as PID 1.

command: ["sh", "-c", "prepare-config && exec /app/server"]

Trade-off: The app still needs its own SIGTERM handler as PID 1, or a small init such as tini to apply default signal behavior.

Handle SIGTERM in the app

Stop accepting new work, finish in-flight requests and exit 0 when SIGTERM arrives.

Trade-off: Takes code changes in every service and testing of the shutdown path, which is rarely exercised.

Raise the grace period

Increase terminationGracePeriodSeconds if the app needs more time to finish work cleanly.

Trade-off: Rollouts, scale-downs and node drains all take longer. A hung process also takes that long to be killed.

Add a short preStop sleep

A preStop hook that sleeps a few seconds gives load balancers time to stop sending traffic before SIGTERM arrives.

Trade-off: The sleep counts against the grace period. It also needs a sleep binary in the image, or the built-in sleep action on clusters that support it.

How to stop it coming back

  • Always read exit code and reason together. Never treat 137 as OOM on its own.
  • Test shutdown in CI: send SIGTERM to the container and check it exits with 0 well before the grace period.
  • Check what the image's STOPSIGNAL is. The nginx image uses SIGQUIT and exited 0 in our lab after a liveness kill.
  • Alert on 137 with reason Error separately from OOMKilled. They have different owners and fixes.

How KubeGraf investigates it

Agents propose competing explanations and cite the evidence behind each one. How KubeGraf handles Kubernetes incidents.

Frequently asked questions

What does exit code 143 mean?

The process got SIGTERM and exited. This is a normal stop. Rollouts, scale downs, drains and liveness failures all send SIGTERM.

What is the difference between SIGKILL and SIGTERM?

SIGTERM asks the process to stop, so it can clean up first. SIGKILL ends it at once and cannot be caught. Kubernetes sends SIGTERM, waits terminationGracePeriodSeconds (30 by default) and then sends SIGKILL.

Why was my container terminated with exit code 137?

Check lastState.terminated.reason first. OOMKilled means it went over its memory limit. Reason Error often means it ignored SIGTERM and was killed when the grace period ran out, which is common when the app runs as PID 1 with no signal handler.

How do I make my app exit cleanly on SIGTERM?

Handle SIGTERM in the app and exit once in-flight work is done. Use the exec form of ENTRYPOINT, or end wrapper scripts with exec, so the app is the process that gets the signal.

Last updated . Try KubeGraf Freemium.

Related

Kubernetes documentation