ExitCode143
KubernetesWARNINGNotablePod LifecycleHIGH confidence

Container received SIGTERM but did not exit within grace period

Production Risk

Medium — repeated 143 exits may indicate requests are being dropped or data is not being flushed properly during rolling updates.

What this means

The container exited with code 143 (128 + signal 15 = SIGTERM). Kubernetes sends SIGTERM to containers during graceful shutdown. Exit code 143 typically means the process caught SIGTERM but then timed out and was sent SIGKILL, or was killed externally before completing shutdown logic.

Why it happens
  1. 1Kubernetes sent SIGTERM due to pod deletion, rolling update, node drain, or preemption.
  2. 2Application did not finish shutdown logic within terminationGracePeriodSeconds (default 30s).
  3. 3Application does not handle SIGTERM and was forcefully killed after the grace period expired.
  4. 4HPA or manual scale-down selected this pod for termination.
How to reproduce

Pod is terminated and the container status shows exit code 143.

trigger — this will error
trigger — this will error
kubectl describe pod my-pod
# Last State: Terminated
#   Exit Code: 143
#   Reason:    Error

expected output

Last State:     Terminated
  Reason:       Error
  Exit Code:    143
  Started:      Mon, 10 Mar 2025 10:00:00 +0000
  Finished:     Mon, 10 Mar 2025 10:00:30 +0000

Fix 1

Implement a SIGTERM handler in the application

WHEN Application does not gracefully handle shutdown

Implement a SIGTERM handler in the application
# Example: Node.js SIGTERM handler
process.on('SIGTERM', () => {
  server.close(() => {
    process.exit(0);
  });
});

Why this works

A SIGTERM handler lets the application drain in-flight requests, close database connections, and exit cleanly before the grace period expires.

Fix 2

Increase terminationGracePeriodSeconds

WHEN Application needs more time to shut down cleanly

Increase terminationGracePeriodSeconds
spec:
  terminationGracePeriodSeconds: 60
  containers:
  - name: my-app
    # ...

Why this works

Increasing the grace period gives the application more time to complete shutdown before Kubernetes sends SIGKILL.

Fix 3

Use a preStop hook to delay SIGTERM

WHEN Load balancer needs time to stop routing traffic before the process exits

Use a preStop hook to delay SIGTERM
lifecycle:
  preStop:
    exec:
      command: ["/bin/sh", "-c", "sleep 5"]

Why this works

The preStop hook runs before SIGTERM, giving upstream load balancers time to remove the pod from rotation and preventing in-flight request drops.

What not to do

Sources
Official documentation ↗

Kubernetes Documentation — Pod Lifecycle: Termination

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Kubernetes errors