Troubleshooting guide
Kubernetes CrashLoopBackOff: how to fix it
CrashLoopBackOff means a container keeps exiting and Kubernetes is waiting longer and longer before restarting it. The answer is in the last crash’s logs and exit code.
3 min read10 sectionsUpdated
On this page
Key points
- It is a symptom, not a cause: the container starts, exits, and restarts with back-off.
- Read the previous container’s logs: the current one may have no output yet.
- The exit code narrows it down: 1 is an app error, 137 is a kill (often OOM), 143 is SIGTERM.
- Liveness probes that are too strict can cause the loop on a healthy app.
kubectl get pods -n prod
kubectl describe pod <pod> -n prod # Last State, Reason, Exit Code, Events
kubectl logs <pod> -n prod --previous # logs from the crashed container
kubectl logs <pod> -n prod -c <container> --previous # multi-container pods
kubectl get events -n prod --sort-by=.lastTimestamp | tail -n 20| Exit code | Meaning | Look at |
|---|---|---|
| 0 | Exited successfully, but a Deployment expects it to keep running | Command finishes instead of serving; wrong entrypoint |
| 1 | Application error | Logs: missing config, failed connection, exception on start |
| 126 / 127 | Command not executable / not found | Image, entrypoint, PATH |
| 137 | Killed by SIGKILL | OOMKilled in Last State; or liveness probe failure |
| 139 | Segmentation fault | Native modules, base image mismatch |
| 143 | SIGTERM | Probe failures or the container being stopped |
The usual causes
- Missing environment variables or secrets: the app throws on start. Check
envFrom, secret names and keys. - Cannot reach a dependency at startup: database or cache not ready. Retry with backoff instead of exiting.
- Liveness probe too aggressive: the app needs 40 s to start, the probe kills it at 10 s. Use a startupProbe, or raise initialDelaySeconds and failureThreshold.
- Out of memory: Reason OOMKilled. Raise the limit or fix the leak; see OOMKilled.
- Wrong image or architecture: an arm64 image on amd64 nodes, or a bad tag.
- File permission problems with read-only root filesystems or non-root users.
startupProbe:
httpGet: { path: /health/live, port: 8080 }
periodSeconds: 5
failureThreshold: 30 # up to 150 s to start
livenessProbe:
httpGet: { path: /health/live, port: 8080 }
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet: { path: /health/ready, port: 8080 }
periodSeconds: 5
failureThreshold: 2When logs are empty
If the container dies before logging, override the command to keep it alive and inspect it, or use an ephemeral debug container:
kubectl debug -it <pod> -n prod --image=busybox:1.36 --target=<container>
# or run the image by hand with a shell
kubectl run debug --rm -it --image=<your-image> --command -- shCatch restarts early
Alert on restart counts rising, not only on pods being down: a pod that restarts every ten minutes may still pass most uptime checks. VitalRix infrastructure monitoring shows clusters, namespaces, workloads and pods with restart counts, CPU and memory against limits. See the Kubernetes monitoring guide.
How long is the CrashLoopBackOff delay?
Kubernetes doubles the wait between restarts, starting at 10 seconds and capped at 5 minutes, and resets it after the container runs successfully for 10 minutes.
Does deleting the pod fix it?
Only if the cause was transient. The Deployment creates a new pod with the same spec, which usually crashes the same way.
Related reading
- Kubernetes readiness probe failed: how to fix it: Fix Kubernetes readiness and liveness probe failures: slow startup, wrong ports, overloaded health endpoints and dependency checks that cause cascading outages.
- Kubernetes pod stuck in Pending: how to fix it: Fix Kubernetes pods stuck in Pending: insufficient CPU or memory, taints, node selectors and unbound PersistentVolumeClaims, using scheduler events.
- Kubernetes pod stuck in Terminating: how to fix it: Fix pods stuck in Terminating: finalizers, unreachable nodes, stuck volumes and processes that ignore SIGTERM, and when force deletion is safe to use.
- CreateContainerConfigError in Kubernetes: how to fix it: Fix Kubernetes CreateContainerConfigError: missing Secrets and ConfigMaps, wrong keys and namespaces, with kubectl commands that show exactly what is absent.
- Server and Kubernetes monitoring: See CPU, memory, disk and running instances for servers, Docker containers and Kubernetes pods beside uptime checks, logs and traces, with a one-file agent.
- net::ERR_FAILED: how to fix it: Fix net::ERR_FAILED in Chrome and the console: CORS preflight failures, service workers, blocked requests, cache problems and extensions, step by step.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.