Kubernetes CrashLoopBackOff: Find the Cause and Fix It

Kubernetes CrashLoopBackOff: Find the Cause and Fix It

Introduction

CrashLoopBackOff is the Kubernetes status every engineer meets sooner or later, and the name explains almost nothing. It is not an error. It is not a cause. It is Kubernetes telling you that a container keeps starting and exiting, and that the kubelet is now waiting before it tries again. The actual error is somewhere else — in the application, in the configuration, in the image, in a probe or in a resource limit — and the status column gives you three words for it, one of which is sometimes Running.

This guide shows you how to find the real cause and fix it, using the method that works in every case: read the pod's last state, read the previous container's logs, and read the events, in that order. It covers what the back-off actually does, the six common causes with their fixes, and how to stop the loop happening again. Every command below is a standard kubectl command, and every output pattern shown is the shape that output takes in real clusters — the describe blocks, the event messages and the exit codes are the ones the official docs record, not invented examples. If you are new to Kubernetes itself, start with our Kubernetes Tutorial for Beginners; if you write the manifests, our Kubernetes Deployment YAML Tutorial is the companion for this one.

The short version: run kubectl describe pod and read the Last State block for the exit code, run kubectl logs --previous for what the crashed run printed, and check the Events section for what the kubelet did. The exit code tells you which of the six causes to look at.

What CrashLoopBackOff Actually Means

A pod's containers run under a restartPolicy, and the default for a Deployment is Always. When a container exits — for any reason and with any exit code — the kubelet starts it again. If it keeps exiting, the kubelet waits longer each time before the next attempt: 10 seconds, then 20, then 40, doubling up to a cap of five minutes. If a container then runs for ten minutes without problems, the delay resets. CrashLoopBackOff is the name of that waiting period, and the pod's status flips between Error, Running and CrashLoopBackOff while the RESTARTS counter grows.

Two consequences catch people out. First, the status column is not reliable on its own: a crash-looping pod can show Running and 1/1 between restarts, because the container is briefly up when you look. Trust RESTARTS instead — a count climbing over minutes means a crash loop, whatever the status word says. Second, the back-off is protective: it stops a broken container consuming the node's CPU in a tight restart loop, and gives you time to read the logs before the next attempt overwrites them.

The cause is always inside the container or in what it needs: the application crashes, is killed, or is told to exit. Kubernetes only reports it. That distinction is the whole method: do not debug Kubernetes, debug the container. The evidence is in the three places this guide covers next.

One timing detail changed in recent versions. Two feature gates touch the back-off: KubeletCrashLoopBackOffMax arrived as alpha in 1.32 and has been beta, on by default, since 1.35; ReduceDefaultCrashLoopBackOffDecay is still alpha in 1.37 and off by default, and with it on, delays start at 1 second and stop growing at 60. You do not need to change either gate to fix a crash loop — the 10-seconds-doubling-to-five-minutes behaviour above is the default on a current cluster.

The Three Commands That Find the Cause

Every CrashLoopBackOff diagnosis starts the same way, and the order matters. Work from the least invasive tool to the most invasive, and stop as soon as you have the cause — most cases are solved by the first two commands.

Command 1: spot the pod. kubectl get pods shows the status and the restart count. Narrow it to a namespace when you know it, and add -o wide when you need the node:

kubectl get pods -n shop
kubectl get pods -n shop -o wide

The output has the shape every Kubernetes engineer recognises:

NAME                      READY   STATUS             RESTARTS   AGE
my-app-6f4d5c7b8-x9kmn    0/1     CrashLoopBackOff   5          10m

READY of 0/1 means the container is not ready, RESTARTS of 5 means it has been restarted five times, and AGE of 10m tells you how long this has been going on. A restart count that grows between two runs of this command, a minute apart, confirms the loop is live rather than historical.

Command 2: read the pod's last state. kubectl describe pod is the single most useful thing to read, and the part that matters sits under Containers:. Skip the top of the output and find the state block:

kubectl describe pod my-app-6f4d5c7b8-x9kmn -n shop

The block looks like this:

    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Wed, 07 Oct 2026 10:12:01 +0200
      Finished:     Wed, 07 Oct 2026 10:12:02 +0200
    Ready:          False
    Restart Count:  6

State tells you only what is happening now — usually Waiting with reason CrashLoopBackOff, which tells you nothing new. Last State is the run that died, and it carries the two facts you came for: a Reason and an Exit Code, plus the start and finish times. How long the container lived is itself a diagnosis: one that died within a second of starting has a startup problem — a bad command, a bad configuration, a missing file. One that ran for several minutes and only then died points somewhere else — memory, a probe, or a dependency that went away while it was running. The Events section at the bottom of the same output is the third place to look: it is where the kubelet writes down what it did to your container and why, and a line like Back-off restarting failed container with a count confirms the loop, while a Liveness probe failed or Failed to pull image line points at the cause directly.

Command 3: read the previous container's logs. Plain kubectl logs shows the current container, which in a crash loop is often brand new or not started yet. Add --previous — short form -p — to get the instance that exited:

kubectl logs my-app-6f4d5c7b8-x9kmn -n shop --previous

For a pod with several containers, add -c <container-name>. The previous logs are the application's own account of what happened: a stack trace, a missing-module error, a connection failure, a panic message. If they are empty, that is a finding in itself — the process exited before it wrote a line, which points at a command problem rather than an application error. Two limits: --previous goes back one container instance only, and if the pod has been deleted, its logs are gone — so read them before you delete anything.

If those three commands have not found the cause, the next steps are kubectl get events -n <namespace> --sort-by='.lastTimestamp' for the cluster-wide picture, and kubectl debug with an ephemeral container where the image has no shell — the technique for distroless images, where kubectl exec has nothing to run.

Reading the Exit Code — the Map from Code to Cause

The exit code in the Last State block is the fastest route from symptom to cause, because each code narrows the search to one family of problems. The table below is the map to use, and the sections after it work through each family in turn.

Exit code / reason What it means Look at
0, reason Completed The process finished successfully The workload type — a one-shot task in a Deployment
1 Generic application error The previous logs: exception, bad config, missing dependency
2 Shell or CLI argument error The command and args in the manifest
126 Command cannot execute Binary not executable, or wrong architecture for the node
127 Command not found The command or entrypoint path in the manifest
137, reason OOMKilled Container killed for exceeding its memory limit Resource limits and actual memory use
143, SIGTERM Container terminated by a signal A liveness probe killing a slow starter, or a shutdown problem

Exit code 0 confuses everyone the first time. A container that exits with code 0 has succeeded — its process finished its job and stopped. But a Deployment expects a long-running process, and its restartPolicy is Always, the only option for Deployments. So Kubernetes restarts the successful container, it succeeds again, and the pod enters CrashLoopBackOff. That is not a bug: it is a workload in the wrong controller. A one-shot task belongs in a Job, a recurring task in a CronJob — change the workload type, do not make the process hang artificially.

Exit code 1 is the most common and the least specific: it means the application failed, and the previous logs will say how — an unhandled exception, a missing environment variable, a bad configuration value, a database that refused the connection. Exit code 2 usually means a shell or CLI argument problem: a flag the binary does not recognise, or an argument in the wrong position. Codes 126 and 127 are command problems: 126 means the binary is present but cannot be executed — a missing executable bit, or an image built for the wrong CPU architecture, such as an arm64 image on an amd64 node; 127 means the command was not found at all, which usually means the command or args in the manifest names a path that does not exist in the image. Exit code 137 is 128 plus 9, the signal number for SIGKILL, and in Kubernetes it almost always means OOMKilled: the container exceeded its memory limit and the kernel killed it. The Last State reason will say OOMKilled outright in that case.

Causes 1–3 — Application Errors, Bad Configuration and Unreachable Dependencies

Cause 1: the application throws an error at startup. Most of the time, the application inside the container is simply failing on startup. Read kubectl logs --previous and you will find the reason in the application's own words: a stack trace, a ModuleNotFoundError or Error: Cannot find module, a panic:, an Address already in use. The fix is in the code or the image, not in Kubernetes, and the fastest way to confirm it is to run the same image locally: docker run --rm myapp:1.0 and see if it fails there too. If it fails locally, the problem is reproducible without Kubernetes, and you can debug it with your normal tools. If it works locally but fails in the cluster, the difference is the environment — which leads to the next two causes.

Cause 2: missing or wrong configuration. The application expects a value that is not there, or is wrong. Wrong environment variables, a missing file, a bad ConfigMap value, a Secret key misspelled in the deployment YAML — any of these will kill an application on startup, and the error in the logs will usually name the missing thing. Check three things in order: that the ConfigMap or Secret exists in the correct namespace, that it contains the expected keys, and that the pod references it correctly in envFrom or valueFrom. A missing ConfigMap or Secret does not always produce CrashLoopBackOff — if the resource does not exist at all, the pod may show CreateContainerConfigError instead, a different status with the same cause and fix. If the container is briefly up between crashes, kubectl exec <pod> -- env shows the environment as the application sees it; if not, kubectl debug with a copied pod inspects it without disturbing the original.

Cause 3: a dependency is not reachable. The application exits because the database, the cache or an upstream API is not ready, or its address is wrong. The log lines to recognise are connection refused, could not translate host name and dial tcp: lookup db: no such host. The first means the address resolved but nothing is listening; the second and third mean the name did not resolve at all, which usually means the Service name is misspelled or the Service is in a different namespace. If the address is wrong, correct it. If the dependency is simply not ready yet, make the application retry with back-off instead of exiting on the first failure — an application that gives up after one failed attempt will crash-loop on every deploy where the database starts slower than the application. An init container that waits for the dependency is the Kubernetes-side alternative, for when you cannot change the application's retry behaviour.

Causes 4–6 — Wrong Command, Resource Limits and Probes

Cause 4: wrong command, args or entrypoint. In Kubernetes, command replaces the image's ENTRYPOINT and args replaces its CMD, and that replacement causes a whole family of crashes. A common mistake is to set command to a shell script that does not exist in the image, or to pass arguments that belong to a different entrypoint. Another is to override the entrypoint with a command that needs a shell — command: ["myapp --flag"] as a single string does not work, because Kubernetes passes it as one argument; it must be split into command: ["myapp"] and args: ["--flag"]. Check what the manifest sets with kubectl get pod <pod> -o jsonpath='{.spec.containers[*].command}' and the same for .args, and compare it with the image's own entrypoint, which docker inspect shows. Exit codes 126 and 127 are the signature of this cause, and the previous logs are often empty, because the process never started far enough to write anything.

Cause 5: resource limits set too low, and OOMKilled. Memory exhaustion is one of the most frequent causes of CrashLoopBackOff in production. If the container exceeds its memory limit, the kernel kills it with OOMKilled, the Last State reason says so, and the exit code is 137. Raising the memory limit blindly might stop the crash, but it does not address whether the application is behaving as expected under load. Base limits on observed usage — staging load tests or production metrics — so the boundary is informed by real behaviour. Check what the pod used with kubectl top pod: a limit only just above steady-state use will kill the container on the first traffic spike, and a limit with no request set means the scheduler may place the pod on a node that cannot spare the memory. CPU limits behave differently — a container that exceeds its CPU limit is throttled, not killed — so a CPU problem shows up as slowness, not a crash loop.

Cause 6: a misconfigured liveness or startup probe. A liveness probe that fails tells the kubelet to kill the container and restart it, and if the probe keeps failing, the restarts become a crash loop. The classic case is a probe that is too aggressive for the application: the probe starts before the application has finished initialising, or its timeout is shorter than the application's response time under load. The fix is to align the probe with the application's real startup behaviour. Increase initialDelaySeconds and timeoutSeconds, but for slower applications the more reliable approach is a startupProbe: while the startup probe is running, the liveness and readiness probes are disabled, and the container is given up to failureThreshold × periodSeconds to start — with the common values of 30 failures at 10 seconds, that is 300 seconds. A second common mistake is using the liveness probe to check an external dependency, such as a database: when the database is slow, the probe fails, the container is killed, and the restart makes the problem worse. Liveness probes should check only the process's own health — a deadlock, a hung thread — never the health of something else. Readiness probes are different: they control whether the pod receives traffic, not whether it is restarted, so a failing readiness probe removes the pod from the Service but does not crash it.

A Worked Diagnosis, End to End

Here is the method applied to a deployment broken on purpose — a busybox image run with the command false, which exits with code 1 the moment it starts. It is the simplest possible crash loop, and it shows the shape of every diagnosis.

Create it and watch:

kubectl create deployment crasher --image=busybox:1.28 -- false
kubectl get pods --watch

The pod appears, its restart count climbs, and its status cycles between Error, Running and CrashLoopBackOff. Describe it, using the pod name from your own output:

kubectl describe pod crasher-6d8f7b9c4d-x2k9p

Skip to the container block. State is Waiting with reason CrashLoopBackOff. Last State is Terminated, reason Error, exit code 1, and the start and finish times are one second apart — a startup problem, not a runtime one. Restart Count is 4 and climbing. At the bottom, the Events section shows the kubelet's own record:

Events:
  Type     Reason   Age   From     Message
  ----     ------   ----  ----     -------
  Warning  BackOff  12s   kubelet  Back-off restarting failed container busybox in pod crasher-6d8f7b9c4d-x2k9p_default(...)

Now the previous logs:

kubectl logs crasher-6d8f7b9c4d-x2k9p --previous

The result is empty. The process exited before it wrote a single line, which matches the diagnosis: the command false exits immediately with code 1, and there is no application to produce output. The fix is to change the command to something that runs — and in a real case, the fix would be whatever the exit code and the logs point at. The pattern is the same every time: describe, read the Last State, read the previous logs, read the events, and let the exit code choose the cause.

Stopping the Loop from Coming Back

Fixing one crash loop is a good day's work; stopping the next one is better. Four practices cover most recurrences. First, test the image before it reaches the cluster. Run it locally with docker run, hit its health endpoint, and run its test suite inside the image. A container that cannot start on a laptop will not start on a node. Add a smoke test to CI that starts the built image and waits for a successful health check before the image is pushed.

Second, set resource requests and limits from observed use, not from guesses. A limit copied from a tutorial is a guess about someone else's application. Measure your own application's memory under load, set the request to its steady-state use and the limit to its peak plus a margin, and revisit both after every release that changes the application's behaviour. Monitor OOMKilled as an alert, not as a status you happen to notice — a container killed once is a warning, and a container killed repeatedly is a crash loop that has already happened.

Third, give slow starters a startup probe. Any application that takes more than a few seconds to initialise — a Java service warming a cache, a Python service loading a model — should have a startupProbe with a generous failure threshold, so the liveness probe never fires during normal startup. The cost is a few lines of YAML; the saving is the crash loop that would otherwise appear on every deploy.

Fourth, make the application resilient to its dependencies. Retry with back-off, wait for readiness, and log clearly when a dependency is missing — including the name of the missing variable or the address that could not be resolved. The application's error message is the first thing you will read in the previous logs, and a message that says which variable is missing saves the ten minutes that a bare stack trace costs. If you are preparing for interviews as well as for production, our Kubernetes Interview Questions and Answers covers CrashLoopBackOff as an interview topic, and the answer interviewers want is this method, not a list of causes.

FAQ

What does CrashLoopBackOff mean?

It means a container keeps starting and exiting, and the kubelet is waiting before it tries again. It is a state, not an error and not a cause — the cause is whatever made the process exit, and you find it in the pod's last state and the previous container's logs.

Which kubectl commands diagnose CrashLoopBackOff?

Three, in order: kubectl get pods to spot the pod and its restart count, kubectl describe pod for the exit code and events, and kubectl logs <pod> --previous for what the crashed run printed. kubectl get events --sort-by='.lastTimestamp' gives the cluster-wide picture, and kubectl debug helps when the image has no shell.

What does exit code 137 mean?

Exit code 137 is 128 plus 9, the signal number for SIGKILL, and in Kubernetes it almost always means OOMKilled — the container exceeded its memory limit and the kernel killed it. The Last State reason will say OOMKilled outright. Check the limits and the actual memory use before raising the limit.

Why does my pod show CrashLoopBackOff when the application exits successfully?

Because a Deployment expects a long-running process and its restart policy is Always. A container that exits with code 0 has succeeded, but Kubernetes restarts it anyway, and the restarts become a crash loop. A one-shot task belongs in a Job, and a recurring task belongs in a CronJob.

How long does Kubernetes wait between restarts?

The back-off starts at 10 seconds and doubles — 10, 20, 40 — up to a cap of five minutes. If the container then runs for ten minutes without problems, the delay resets. The timing is a protective mechanism to stop a broken container consuming the node's CPU in a tight restart loop.

Conclusion

CrashLoopBackOff is Kubernetes doing its job: it is telling you, repeatedly and with a growing restart counter, that a container cannot stay up. The diagnosis is three commands — kubectl get pods, kubectl describe pod and kubectl logs --previous — and the exit code in the Last State block is the map from symptom to cause: 0 means the wrong workload type, 1 means an application error, 126 and 127 mean a command problem, 137 means out of memory, and a failing probe means the probe, not the application, is misconfigured. Fix the cause, not the status, and the status fixes itself.

Build the habit: test the image locally, set limits from observed use, give slow starters a startup probe, and make the application say clearly what is missing when it fails. Then go deeper with our Kubernetes Tutorial for Beginners for the fundamentals, and our Kubernetes Deployment YAML Tutorial for the manifests the fixes live in.

Sources checked 30 Nov 2026: Kubernetes documentation, Debug Running Pods (back-off behaviour, kubectl describe pod, kubectl logs --previous, ephemeral debug containers); Kubernetes documentation, Liveness, Readiness and Startup Probes (probe types, startup probe disabling liveness and readiness until it succeeds, caution against incorrect liveness probes causing cascading failures); 100daysofkubernetes.io, CrashLoopBackOff chapter, rewritten Oct 2026 for Kubernetes 1.37 (back-off 10s doubling to 5-minute cap, 10-minute reset, KubeletCrashLoopBackOffMax beta since 1.35, ReduceDefaultCrashLoopBackOffDecay alpha in 1.37, busybox false worked example shape); troubleshooting guides checked 30 Nov 2026 (exit-code table including 0 Completed, 1, 2, 126, 127, 137 OOMKilled; event message "Back-off restarting failed container"; log lines "connection refused" and "could not translate host name" as dependency-failure signatures). NOT VERIFIED and therefore not stated as fact above: any specific percentage of CrashLoopBackOff cases attributable to a single cause (no reliable source states one); the exact behaviour of the alpha ReduceDefaultCrashLoopBackOffDecay gate beyond the timings stated in the 100daysofkubernetes chapter. External references: Kubernetes documentation — Debug Running Pods · Kubernetes documentation — Liveness, Readiness and Startup Probes.

—

Scroll to Top