CrashLoopBackOff means Kubernetes is waiting before restarting a container that has repeatedly stopped. To fix it, inspect why that container terminated, then correct the application or workload configuration responsible. The waiting message describes the restart behavior; it does not identify the original failure.

Start with the affected container's logs and termination details. A Pod can contain several containers, so record which one is restarting. Keep useful logs before replacing the Pod, because its previous attempt may be the best evidence you have.

The walkthrough below includes an original downloadable lab tested on a disposable Kubernetes v1.34.0 cluster with BusyBox 1.37.0. The general investigation also applies to other recent versions, but restart timing can vary with Kubernetes configuration and feature gates.

Start with logs, state, and events

Confirm your cluster context and set the actual namespace, Pod, and container names. The first commands only inspect state:

kubectl config current-context
kubectl -n "$WORKLOAD_NAMESPACE" get pod "$WORKLOAD_POD" -o wide
kubectl -n "$WORKLOAD_NAMESPACE" describe pod "$WORKLOAD_POD"
kubectl -n "$WORKLOAD_NAMESPACE" logs "$WORKLOAD_POD" -c "$WORKLOAD_CONTAINER" --tail=100
kubectl -n "$WORKLOAD_NAMESPACE" logs "$WORKLOAD_POD" -c "$WORKLOAD_CONTAINER" --previous --tail=100

--previous requests the preceding instance of that container in the same Pod. It does not retrieve every historical restart or a deleted Pod's logs. If there is no previous instance, the command can report that none exists. Use centralized logging when the relevant attempt is no longer available. kubectl logs reference.

In the description, inspect the current state, Last State, reason, exit code, restart count, and recent events. Correlate the times with a release, changed configuration, or traffic increase. An exit code is one clue; combine it with the termination reason and application evidence before deciding what happened.

Choose the next check from the evidence

Use the first specific observation to narrow the investigation:

  • A startup log names a missing setting: inspect the Deployment's environment and configuration references. Confirm the setting name and expected source without exposing Secret values.
  • The recorded reason is OOMKilled: compare configured memory limits with historical usage and node evidence. A quiet replacement container's current memory use cannot reconstruct the earlier peak.
  • Events show failed liveness or startup probes: inspect their path, port, thresholds, and timing alongside startup logs. Check whether the endpoint describes a condition that should cause a restart.
  • The process exits successfully: check the command and workload type. A short-lived task can exit with code zero and still be restarted under the configured policy.
  • Logs show permission or missing-file errors: check the image contents, mount paths, effective identity, and access controls. Repeated restarts do not supply the missing file or permission.
  • The container exits while connecting to a dependency: distinguish an unavailable dependency from an incorrect hostname, credential, or application behavior that exits rather than handling a transient failure.

Some failures produce few application logs. The container might stop before its logger starts, or the useful error may be in an event. Follow the recorded state and termination message rather than assuming an empty log means the application was healthy. Pod failure investigation.

A worked missing-configuration failure

Our lab has one Deployment called worker in esre-crashlab. Its startup script requires QUEUE_URL. If the setting is missing, the script prints a message and exits with code 1. When the setting exists, it serves a small HTTP health endpoint. It never connects to a real queue.

In the local test, the container reached CrashLoopBackOff after repeated failures. Its previous logs contained:

startup failed: QUEUE_URL is required

The recorded last termination reason was Error, with exit code 1. That evidence points to the startup guard. There is no evidence here for a queue outage, because this fixture stops before any queue communication and does not implement one.

Changing the desired workload configuration supplied the missing setting. Kubernetes created a replacement Pod from the updated template; that Pod became Ready and returned ok through the Service. This is a small teaching reproduction of one cause, not a claim that configuration is responsible for every crash loop.

Run the reproduction in a disposable cluster

Download the CrashLoopBackOff lab manifest. It creates a dedicated namespace, a deliberately broken Deployment, and a ClusterIP Service. Set LAB_CONTEXT to a disposable cluster context before applying it. The example creates no cloud load balancer.

: "${LAB_CONTEXT:?Set LAB_CONTEXT to your disposable cluster context}"
kubectl --context "$LAB_CONTEXT" apply -f crashloopbackoff-lab.yaml
kubectl --context "$LAB_CONTEXT" -n esre-crashlab get pods -l app=esre-worker

Once the Pod exists, wait for the waiting reason and read its preceding attempt:

kubectl --context "$LAB_CONTEXT" -n esre-crashlab wait pod -l app=esre-worker \
  --for=jsonpath='{.status.containerStatuses[0].state.waiting.reason}'=CrashLoopBackOff \
  --timeout=120s
kubectl --context "$LAB_CONTEXT" -n esre-crashlab logs deployment/worker \
  -c worker --previous --tail=20

Image downloads and scheduling can take time. If the wait expires, inspect the Pod events; an image-pull or scheduling problem prevents the intended startup failure from being reached.

Apply the narrow correction to this lab's Deployment:

kubectl --context "$LAB_CONTEXT" -n esre-crashlab set env deployment/worker \
  QUEUE_URL=amqp://queue.practice.invalid
kubectl --context "$LAB_CONTEXT" -n esre-crashlab rollout status deployment/worker --timeout=120s
kubectl --context "$LAB_CONTEXT" -n esre-crashlab exec deployment/worker -c worker -- \
  wget -qO- http://worker:8080/health

The final request should return ok. The address assigned to QUEUE_URL is an illustrative value, not a queue supplied by this lab. The test demonstrates configuration, startup, readiness, DNS, and Service reachability for this small workload. It does not demonstrate message delivery. Remove only the lab resources when finished:

kubectl --context "$LAB_CONTEXT" delete namespace esre-crashlab

For a real application, make the corresponding change in its source-controlled configuration or deployment system. An imperative fix can be overwritten by the next reconciliation or release.

What if probes keep restarting the container?

Readiness determines whether a Pod is ready to receive normal traffic; a failed readiness probe alone does not restart its container. Failed liveness or startup probes can trigger restarts after their configured thresholds. A startup probe delays readiness and liveness probing until initialization succeeds.

For a slow-starting application, measure initialization time and check whether the probe permits that startup window. Also check the actual endpoint and port. Changing a timeout cannot repair a probe that points to a path the server never serves. Making liveness depend on an unavailable external service can spread that dependency's outage into repeated restarts. Probe behavior.

Try a follow-up question before changing the lab: the process stays alive, but /health starts returning 503. With this manifest's readiness probe and no liveness probe, would you expect a restart? You should expect the Pod to become unready; readiness failure by itself does not cause a restart. Confirm the distinction in events and restart counts.

How is CrashLoopBackOff different from ImagePullBackOff?

ImagePullBackOff concerns retrying a failed image pull. Inspect the image reference, registry access, credentials, and image availability before investigating application startup. In a crash loop, the affected container has run and stopped, so its logs and termination state can help explain that attempt. A Pod with several containers can show different failures at once; inspect each container rather than treating the Pod's printed status as the whole diagnosis.

Likewise, a Pod's phase can remain Running while one of its containers is restarting. The displayed status column and the Pod phase are different views of the workload. Pod lifecycle.

How do you know the fix worked?

Check the replacement workload at the intended replica count. Observe that restart counts remain stable for a period that covers the trigger, and check readiness and recent logs. Reproduce the request or work that failed, under representative demand where appropriate.

For a real confirmation worker, that means checking successful delivery and backlog age, not just the process being alive. For the lab, it means a successful Service request and a Ready container after the setting is added. Record the original evidence, the change, and the recovery observation so another engineer can review the conclusion.

For broader practice, use the Kubernetes interview scenarios. The on-call troubleshooting guide explains how to keep the investigation tied to customer impact.