CrashLoopBackOff
Your container keeps crashing and Kubernetes keeps restarting it.
Why this happens
Kubernetes expects containers to run continuously. When a container exits (whether from an error or intentionally), the kubelet restarts it with exponential backoff delays (10s, 20s, 40s, up to 5 minutes). CrashLoopBackOff is the status shown during these increasing wait periods between restart attempts.
Fix 1: Check the logs
kubectl logs my-pod
kubectl logs my-pod --previous # Logs from the crashed container
Fix 2: Check the pod events
kubectl describe pod my-pod
Look at the βEventsβ section and βLast Stateβ for exit codes.
Fix 3: Common causes
- Exit code 1 β application error. Check logs.
- Exit code 137 β out of memory (OOMKilled). Increase memory limits.
- Exit code 0 β container exited successfully but K8s expects it to keep running. Make sure your app doesnβt exit.
resources:
limits:
memory: "512Mi" # Increase if OOMKilled
requests:
memory: "256Mi"
Fix 4: Debug with a shell
kubectl run debug --image=myimage --command -- sleep 3600
kubectl exec -it debug -- /bin/sh
Alternative solutions
Override the entrypoint to keep the container alive for debugging:
kubectl run debug --image=myimage --overrides='{"spec":{"containers":[{"name":"debug","command":["sleep","infinity"]}]}}'
Check liveness/readiness probes β misconfigured probes can kill healthy containers. Temporarily remove probes to confirm the app starts correctly.
Prevention
- Always test your container image locally with
docker runbefore deploying to Kubernetes. - Set appropriate resource requests/limits based on actual usage metrics.
Related: Kubernetes: OOMKilled fix Β· Docker vs Kubernetes