CrashLoopBackOff is a symptom, not a cause. The fix is in the crashed container's last words.
What it means
CrashLoopBackOff is not the error itself. It is the kubelet telling you: this container keeps exiting, and I am waiting before I start it again. With the default restartPolicy: Always, the wait starts at 10s and doubles (20s, 40s, 80s...) up to a 5-minute cap. After 10 minutes of clean running, the timer resets. (Newer Kubernetes releases let admins tune the cap in kubelet config; the default is unchanged.)
The real question is always: why did the container exit?
Usual causes
- App error at startup: missing env var, bad config, failed DB connection, unhandled exception (exit 1 or similar).
- Wrong command or entrypoint: binary not found (exit 127), not executable (exit 126).
- Process exits cleanly (exit 0) because it daemonised or the script finished, but a Deployment expects it to keep running.
- Liveness probe kills a slow-starting app (Events show
Liveness probe failed). - Memory limit hit: Reason
OOMKilled, exit 137. - A broken ConfigMap or Secret shipped with the release.
Debug commands
Start with the exit code and reason, then the logs of the instance that died:
kubectl get pod <pod> -n <ns> kubectl describe pod <pod> -n <ns> # Last State, Exit Code, Reason, Events kubectl logs <pod> -n <ns> --previous # add -c <container> for multi-container pods kubectl get events -n <ns> --sort-by=.lastTimestamp
If the container dies too fast to inspect, start a copy with a shell instead of the real command:
kubectl debug <pod> -n <ns> -it --copy-to=<pod>-debug --container=<container> -- sh
Then check env, mounted files and whether the binary runs by hand. Delete the copy when done.
If the crash started with a release, compare what changed:
kubectl rollout history deployment/<name> -n <ns> kubectl rollout undo deployment/<name> -n <ns> # restore service first if users are hit
Fixes by exit code
| Signal | Likely fix |
|---|---|
Exit 1, stack trace in --previous | Fix config, env or dependency the app needs at boot |
| Exit 0, Reason Completed | Run the process in the foreground as PID 1, or use a Job |
| Exit 126 / 127 | Fix command/args, file permissions, or the image |
| Exit 137, Reason OOMKilled | Right-size the memory limit or fix the leak |
| Liveness probe failed | Add a startupProbe, correct the probe path or port |
Common wrong fix
kubectl delete pod and hoping. The ReplicaSet creates an identical pod from the same spec, so it crashes the same way. You also throw away the --previous logs you needed, and the fresh pod's back-off starts again from 10s, which only makes it look briefly better. Removing the liveness probe entirely is the other trap: the loop stops, but now a hung app stays in rotation with nobody restarting it. Find the exit reason first, then change the spec.