CrashLoopBackOff — container keeps crashing and restarting
kubectl get pods shows CrashLoopBackOff status
Focused incident mode — strips away everything but this runbook.
Symptoms
- kubectl get pods shows CrashLoopBackOff status
- Pod restart count climbs with each cycle (10s, 20s, 40s...)
- Container never reaches Ready/Running
Follow the exit code first: 137 → memory path, 1/x → application path, 0 → probe path. Restart backoff is exponential; do not blast-restart a crashing pod.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Pod status and restart count
kubectl get pod <pod> -n <namespace> -o wideLast terminated state
kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[0].lastState}'
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- kubectl logs <pod> --previous shows a stack trace before death
- Exit code is 1 or another nonzero app code
- Restarts follow a predictable back-off pattern
Confirm before fixing
kubectl logs <pod> -n <namespace> --previous | tail -50Tail previous logs for the crash reason
Expected: A panic or error message shortly before exit
Fix
kubectl set image deployment/<deploy> <container>=<image>:<fixed-tag>Deploy a fixed image once the bug is patched
Expected: deployment.apps/<deploy> image updated
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
kubectl logs <pod> -n <namespace> --previousGet the logs from the crashed instance
kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}'Check the exit code (137 = OOM, 1 = app error)
kubectl describe pod <pod> -n <namespace> | tail -30Review events for probes, mounts, and image pulls
kubectl top pod <pod> -n <namespace> --containersCheck live memory/CPU usage to confirm OOM
Prevention
- Set memory requests and limits with buffer above peak observed usage.
- Set readiness + liveness probes with initialDelaySeconds larger than worst-case startup.
- Use start meshing or startupProbe for slow-to-start applications.
- Keep secrets and configmaps versioned in the same repo as the manifest.
Related runbooks
Same stack, same failure family — worth a skim.
Exit code 137 on the container
Pod stuck in ImagePullBackOff or ErrImagePull
kubectl get pods shows Pending for minutes
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.