How to Fix CrashLoopBackOff in Kubernetes
CrashLoopBackOff means your container keeps dying on startup and Kubernetes keeps restarting it slower each time. Here's the diagnosis flow we actually use.
Key takeaways
- CrashLoopBackOff means your container keeps exiting and the kubelet is waiting longer between restarts, 10 seconds doubling to a 5-minute cap.
- Find why it exited with kubectl logs --previous and the exit code in kubectl describe pod.
- Exit 1 is an app error, 137 is a memory or probe kill, 127 a bad entrypoint.
On this page
Fix CrashLoopBackOff by finding why the container exits: run kubectl logs <pod> --previous to read the crashed instance's output, then kubectl describe pod <pod> for the exit code and events. The status itself is just Kubernetes backing off restarts. Exit 1 means an app error, 137 a memory or probe kill, 127 a bad entrypoint.
Verified against
Kubernetes 1.37 (1.37.2, released 2026-10-28), kubectl 1.37, against the kubernetes.io Pod lifecycle, debug running pods, probe configuration and kubectl logs reference pages. Checked October 2026.
A pod goes CrashLoopBackOff and half the team starts guessing. It's almost never a mystery once you read the right output, and the order you read it in matters more than any single command.
Here's what the status actually means. Your container starts, runs for a bit (sometimes milliseconds), and exits. The kubelet restarts it with an exponential backoff that the Kubernetes docs give as 10s, 20s, 40s and so on, capped at 300 seconds (5 minutes), and reset once the container runs for 10 minutes without trouble. That growing delay is the "backoff." The "crashloop" is the part where your process refuses to stay up. So CrashLoopBackOff is not an error in itself; it's Kubernetes telling you it's tired of restarting something that won't stay alive.
As of Kubernetes 1.35 the KubeletCrashLoopBackOffMax feature is beta and on by default, so a node's kubelet config can lower that cap with crashLoopBackOff.maxContainerRestartPeriod. If your restarts come faster than the textbook numbers, that's why.
The container is crashing. Your job is to find out why it exited, not why Kubernetes backed off.
The diagnosis flow
Start here, every time. First look at the pod:
kubectl get pods
NAME READY STATUS RESTARTS AGE
api-7d9f8c6b4-2xqzk 0/1 CrashLoopBackOff 6 4m12s
Six restarts in four minutes. Now describe it:
kubectl describe pod api-7d9f8c6b4-2xqzk
Scroll to the container state and the events at the bottom. This is the single most useful block:
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Wed, 08 Jul 2026 10:22:14 +0000
Finished: Wed, 08 Jul 2026 10:22:14 +0000
Restart Count: 6
Started and Finished at the same second means the process died on boot. The exit code is your first real clue (more on codes below).
Now the opinionated part: read the previous container's logs before anything else.
kubectl logs api-7d9f8c6b4-2xqzk --previous
The --previous flag (short form -p) is the whole game; the kubectl reference describes it as printing "the logs for the previous instance of the container in a pod if it exists." Without it, kubectl logs shows the current container, which may be freshly restarted and empty, or already dead again by the time you run it. --previous shows the instance that actually crashed. Most of the time the stack trace or panic is sitting right there, and you can skip the guessing entirely.
If logs are empty, check events across the namespace:
kubectl get events --sort-by=.lastTimestamp
That surfaces the things logs won't: failed mounts, image pull problems, OOM kills, probe failures.
Common causes and how to fix them
Application error or unhandled exception (exit 1). The most common case. Your app throws on startup: a nil pointer, an unhandled promise rejection, a bad migration. --previous logs show the trace. Fix the code or roll back the image. Exit code 1 is a generic application failure, so treat the logs as truth, not the code.
Bad or missing config / env var. The app starts, can't find DATABASE_URL or a required flag, and bails. Logs usually say something like panic: required env DATABASE_URL not set. Check what the pod actually received:
kubectl exec api-7d9f8c6b4-2xqzk -- env | grep DATABASE
If the pod won't stay up long enough to exec, inspect the ConfigMap and Secret refs in the deployment spec directly, or attach a debug copy with kubectl debug <pod> -it --copy-to=<pod>-debug --container=<name> -- sh, which the Kubernetes "Debug Running Pods" page shows for exactly this case. A typo'd configMapKeyRef name silently gives you nothing.
Failed dependency (DB not reachable). The app boots, tries to connect to Postgres or Redis, times out, and exits instead of retrying. Logs show connection refused or a DNS failure. Two fixes: make the app retry with backoff instead of dying, and confirm the dependency is actually up and its Service resolves:
kubectl exec api-7d9f8c6b4-2xqzk -- nslookup postgres.default.svc.cluster.local
A hard crash on a transient dependency blip is a bug in your app, not in Kubernetes. Startup dependencies should be patient.
Failing liveness probe killing a healthy app. This one fools people. The app is fine but slow to warm up, the liveness probe hits /healthz before the app is ready, fails, and the kubelet kills the container. Restart, repeat, CrashLoopBackOff. You'll see it in describe:
Warning Unhealthy kubelet Liveness probe failed: HTTP probe failed with statuscode: 500
Normal Killing kubelet Container failed liveness probe, will be restarted
The fix is a startupProbe, which holds off liveness and readiness checks until it succeeds:
# deploy/api.yaml (container spec excerpt)
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 10
That gives the app up to 300 seconds (30 × 10s) to boot before liveness takes over. Liveness should catch a wedged app, not punish a slow boot.
OOMKilled (exit 137). The container hit its memory limit and the kernel killed it. Describe shows Reason: OOMKilled and Exit Code: 137 (128 + signal 9). Either the limit is too low or the app is leaking. Raise resources.limits.memory if the workload legitimately needs it, or fix the leak. Don't just keep bumping the limit forever.
Missing file or permission denied. Often after switching to a non-root user or a read-only filesystem. Logs show permission denied or no such file or directory. Check your securityContext, volume mounts, and whether the image expects to write somewhere it no longer can.
Wrong command or entrypoint (exit 127 / 126). Exit 127 is "command not found," 126 is "found but not executable." Usually a bad command: / args: override in the manifest, or a typo in the binary path. The container never really runs your app at all.
Exit codes worth memorizing
The full table, including the less common ones, is in our Kubernetes exit codes reference.
- 0: clean exit. If it's crashlooping on 0, your process finishes and has nothing to keep it running (Deployments use
restartPolicy: Always, so even success restarts). - 1: generic app error. Read the logs.
- 126 / 127: entrypoint not executable / not found.
- 137: SIGKILL, almost always OOMKilled or a probe kill.
- 139: SIGSEGV, a segfault.
- 143: SIGTERM. Something asked the process to stop (a probe failure, rollout or eviction) and it exited on the signal.
The checklist
Run these in order and you'll rarely get stuck:
kubectl get pods: confirm the status and restart count.kubectl describe pod <pod>: read Last State, Reason, and Exit Code.kubectl logs <pod> --previous: read the crash from the dead container first.kubectl get events --sort-by=.lastTimestamp: catch mounts, probes, OOM, image pulls.- Map the exit code (137 = memory, 127 = entrypoint, 1 = app error).
- Reproduce locally with the same image and env if the logs aren't enough.
- Check probes before assuming the app is broken.
If you want a broader reference for the surrounding failure modes, our Kubernetes troubleshooting guide covers the pod lifecycle states around this one.
Questions people ask
How long does CrashLoopBackOff wait between restarts?
By default the kubelet waits 10 seconds after the first crash, then doubles the delay each time (20s, 40s, and so on) up to a cap of 300 seconds, per the Kubernetes Pod lifecycle docs for 1.37. If the container then runs for 10 minutes without problems, the timer resets. Nodes can lower the cap through maxContainerRestartPeriod in the kubelet config.
Why does kubectl logs show nothing for a CrashLoopBackOff pod?
Without --previous, kubectl logs reads the current container instance, which is often waiting in backoff or freshly started with no output yet. Run kubectl logs <pod> --previous to see the instance that crashed. If that is empty too, the process died before writing anything, so check kubectl describe pod for the exit code, OOMKilled, probe failures or mount errors in the events.
How do I stop a pod from crashlooping while I debug it?
Scale the Deployment to zero with kubectl scale deploy/<name> --replicas=0 to stop the churn, or create a debug copy whose command is a shell: kubectl debug <pod> -it --copy-to=<pod>-debug --container=<name> -- sh. The copy runs the same image and env without your entrypoint, so you can inspect files, config and connectivity by hand.
The call we'd make
Read --previous logs first, always. Everything else is confirmation. The exit code narrows it (137 sends you to memory and probes, 127 to your entrypoint, 1 to the application), but the crashed container's own log line is what tells you the truth. Resist the urge to bump memory limits or loosen probes before you've actually read why the thing died, because the fastest fix is the one aimed at the real cause.
Sources
Cite this article
Kiril Urbonas (2026). How to Fix CrashLoopBackOff in Kubernetes. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/fix-crashloopbackoff
[How to Fix CrashLoopBackOff in Kubernetes](https://www.devopsness.com/blog/fix-crashloopbackoff) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
AIOps Explained: AI for IT Operations in 2026
AIOps applies machine learning to your operational telemetry to cut alert noise, catch anomalies early, and speed up incident response.
Fix Git "Updates Were Rejected" on Push
Your push bounces because the remote moved on without you. Here is how to catch up cleanly, when to rebase versus merge, and when a force-push is actually safe.
GitHub Actions Self-Hosted Runners: Why Switch and What Breaks
Bills hit $3,400/mo for runner minutes. We moved to self-hosted on EKS spot. The savings were real; the surprises were too.
You might have missed
Evergreen posts worth revisiting.