Runbook: Fix pod stuck in CrashLoopBackOff
Find out why a container keeps restarting and get the pod Running again.
Symptoms
Section titled “Symptoms”kubectl get podsshowsCrashLoopBackOffand theRESTARTScount keeps climbing.- Events show
Back-off restarting failed container. - Alert:
KubePodCrashLooping.
Impact & urgency
Section titled “Impact & urgency”If the deployment still has healthy replicas, users may not notice yet. If all replicas crash, the service is down: go straight to Fix → roll back below.
-
Read the logs of the container that died, not the new one that is starting up: Kubernetes: Show logs of the previous crashed container
Terminal window kubectl logs <pod> -n <namespace> --previous -
Read the last termination reason and exit code: Kubernetes: Describe a pod to see events
Look at
Last State: Terminated,Reason,Exit Code:Exit code / reason Usually means OOMKilled, 137Hit the memory limit 1 App error at startup (config, missing env var, failed migration) 126 / 127 Bad entrypoint or command not found in the image 143 SIGTERM: often a liveness probe killing a slow-starting app -
Check recent events in the namespace for probe failures and missing Secrets/ConfigMaps: Kubernetes: List recent events sorted by time
-
Did something just change?
kubectl rollout history deployment/<deployment> -n <namespace>.
- Bad release (started right after a deploy): roll back first, debug later. Kubernetes: Roll back a deployment
- OOMKilled: compare usage with the limit (Kubernetes: Show pod CPU and memory usage), raise
resources.limits.memoryor fix the leak. - Missing config / secret: the logs name the variable. Fix the ConfigMap/Secret, then restart the deployment.
- Liveness probe too aggressive: add a
startupProbeor raiseinitialDelaySeconds/failureThreshold.
Verify
Section titled “Verify”kubectl get pods -n <namespace> -w:RESTARTSstops increasing and the pod isRunning+READY 1/1.- Kubernetes: Watch rollout status exits 0.
Prevent / follow-up
Section titled “Prevent / follow-up”- Set memory requests = limits for critical workloads; alert at 80% of the limit.
- Use
--atomicon Helm deploys so failed releases roll back automatically. - Add a
startupProbefor apps that take more than ~10s to boot.
Related
Section titled “Related”My DevOps Playbook by Angelo John Calleja