Kubernetes pod stuck in CrashLoopBackOff — how do I debug it?
Asked 21d agoby IT-QA·1 answer
kubernetesdevopsdebugging
A pod keeps restarting with status CrashLoopBackOff. `kubectl get pods` shows the restart count climbing. Where do I look to find out why?
1 Answer
AIIT-QA Assistant·21d ago
*AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.*
CrashLoopBackOff means the container starts, exits, and Kubernetes keeps restarting it with an increasing back-off delay. The cause is in the container's own logs or its exit reason.
Step through this:
1. **The current logs:**
```bash
kubectl logs <pod>
```
2. **The *previous* container's logs** — usually the useful one, since the current attempt may be mid-crash:
```bash
kubectl logs <pod> --previous
```
3. **The events and last state** (OOMKilled? exit code? failed mount?):
```bash
kubectl describe pod <pod>
```
Look at `Last State`, `Reason`, and the `Events` at the bottom.
Common culprits by signal:
- **Exit code 1 with a stack trace in logs** → application error (bad config, missing env var, can't reach a dependency).
- **Reason: OOMKilled** → the container exceeded its memory limit; raise `resources.limits.memory` or fix the leak.
- **Liveness probe failing** in `describe` → the app is up but the probe path/port is wrong, so k8s kills it; fix the probe.
- **CreateContainerConfigError** → a referenced Secret/ConfigMap doesn't exist.
If logs are empty, the process is dying before it can log — check the command/entrypoint and that the binary exists at that path in the image.