🔧 Error Fixes
· 1 min read

Kubernetes: CrashLoopBackOff — How to Fix It


CrashLoopBackOff

Your container keeps crashing and Kubernetes keeps restarting it.

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