A pod is stuck in CrashLoopBackOff. How do you troubleshoot it?
In one line: CrashLoopBackOff means the container keeps starting and crashing, and Kubernetes is waiting longer between restarts; check the logs of the previous crash, the pod events and the exit code, then fix the cause.
Step 1 — Look at the pod
kubectl get pods -n orders
kubectl describe pod orders-7d9f-abc -n orders
In describe, check:
- Last State / Reason / Exit Code:
OOMKilled(exit 137) → memory limit too low or a memory leak.- Exit code
1→ application error. - Exit code
127→ command not found (wrong entrypoint).
- Events — image pull problems, probe failures, volume mount errors.
Step 2 — Read the logs of the crashed container
kubectl logs orders-7d9f-abc -n orders --previous
--previous shows the logs from the run that crashed, not the new one that just started.
Step 3 — Common causes and fixes
- App error on startup — missing environment variable, bad config, can't connect to the database. Fix config/Secrets or the dependency.
- Wrong command or entrypoint — typo in
command/args, missing binary. - OOMKilled — increase the memory limit or fix the leak.
- Liveness probe failing — wrong path/port, or initial delay too short, so Kubernetes kills a healthy-but-slow app. Add a startup probe or fix the probe.
- Missing ConfigMap/Secret or file permission problems (for example running as non-root but writing to a root-owned folder).
- The process exits immediately — the main process finishes (for example a script with no long-running command), so the container stops.
Step 4 — Dig deeper if needed
- Run the same image locally:
docker run -it myrepo/orders:1.4.2 sh. - Temporarily override the command to
sleep 3600andkubectl execin to investigate. - Use
kubectl debugwith an ephemeral debug container. - Check recent changes: new image, new config, a dependency outage.
Example: a new release crashed with "Error: DB_HOST is not defined". The new code expected a variable the Helm values didn't set. Adding it to the ConfigMap fixed the issue, and the team added a startup check in the pipeline's integration test.
Tip for interviews: mention kubectl logs --previous and exit codes like 137 — they show you've actually debugged this.