Home KubernetesHow to Troubleshoot CrashLoopBackOff Pods in Kubernetes

How to Troubleshoot CrashLoopBackOff Pods in Kubernetes

by Knowledge Base Linux
How to Troubleshoot CrashLoopBackOff Pods in — How to Troubleshoot CrashLoopBackOff Pods in Kubernetes

This article covers How to Troubleshoot CrashLoopBackOff Pods in in detail. Few sights frustrate a Kubernetes beginner more than a pod column that reads CrashLoopBackOff. The pod starts, dies, restarts, and dies again, each time with a longer wait. The good news: learning how to troubleshoot CrashLoopBackOff in Kubernetes is mostly learning a repeatable investigation sequence, because the status itself is not the root cause — it is Kubernetes telling you the container keeps exiting. This guide gives you the exact workflow administrators use to troubleshoot CrashLoopBackOff in Kubernetes, plus a checklist of the causes behind 95 percent of cases.

What CrashLoopBackOff Actually Means – How to Troubleshoot CrashLoopBackOff Pods in

When a container in a pod exits — for any reason — the kubelet restarts it according to the pod’s restart policy (default: Always). If the container keeps failing, Kubernetes backs off exponentially between restarts: 10 seconds, 20, 40, up to a 5-minute cap. CrashLoopBackOff is simply the pod’s status while it sits in that waiting period. Your job is to find out why the container exits, not to “fix” the backoff.

kubectl get pods
NAME                    READY   STATUS             RESTARTS   AGE
web-7d9f8c6b5-x2abc     0/1     CrashLoopBackOff   7          12m

The Workflow to Troubleshoot CrashLoopBackOff in Kubernetes – How to Troubleshoot CrashLoopBackOff Pods in

Step 1: Describe the pod

Always start here. The Events section at the bottom tells you what the kubelet saw — image pull problems, probe failures, OOM kills, and the exit pattern:

kubectl describe pod web-7d9f8c6b5-x2abc

Look specifically for Last State: Terminated with its Reason and Exit Code, and for repeated Back-off restarting failed container warnings.

Step 2: Read the logs of the crashed container

# Logs of the current (probably already dead) container
kubectl logs web-7d9f8c6b5-x2abc

# Logs of the PREVIOUS crashed instance — the key trick
kubectl logs web-7d9f8c6b5-x2abc --previous

# Multi-container pods: pick the container explicitly
kubectl logs web-7d9f8c6b5-x2abc -c app --previous

The --previous flag is the single most valuable trick when you troubleshoot CrashLoopBackOff in Kubernetes: the current container may not have run long enough to log anything, but the previous attempt usually wrote the fatal error before dying. Application stack traces, missing configuration messages, and failed database connections all show up here.

Step 3: Interpret the exit code

  • Exit 0 — the process finished “successfully” and exited. Your container’s command simply ends (a common mistake: the app daemonizes itself, so the main process returns).
  • Exit 1 — generic application error. The logs will tell you why.
  • Exit 126 / 127 — command cannot run or not found: wrong entrypoint, missing binary, bad file permissions.
  • Exit 137 — killed by SIGKILL, almost always the OOM killer (the container exceeded its memory limit) or an external kill.
  • Exit 143 — SIGTERM; the pod was terminated, often a red herring during rollouts.
https://kblinux.com/wp-content/uploads/2026/10/media-generation-k8s-logs-terminal-0-60990848-fc8f-4595-97d6-560422607eb8.webp

The 8 Most Common Causes (and Fixes)

  1. Application bug or bad configuration — the app throws at startup. Read the --previous logs; fix the config value or code.
  2. Missing ConfigMap or Secret keys — the pod starts but the app exits when a required env var is empty. Verify the objects exist in the same namespace and contain the expected keys; our ConfigMap and Secret guide explains the mechanics.
  3. OOMKilled — describe shows Reason: OOMKilled. Raise the memory limit in the Deployment, or fix the application’s memory usage. Check current usage with kubectl top pod.
  4. Failing liveness probe — the app runs, but the probe endpoint never succeeds, so Kubernetes kills and restarts it. During rollout this looks like a crash loop; the describe Events show Liveness probe failed. Fix the probe path/port or increase initialDelaySeconds for slow starters.
  5. Wrong command or arguments — a typo in command:/args:, or an image whose entrypoint expects a subcommand. Test the exact command locally in Docker.
  6. Dependency not ready — the app exits when the database is unreachable instead of retrying. Add retry logic or an init container that waits for the dependency.
  7. Image or architecture mismatch — an image built for another CPU architecture produces exec format error in logs. Rebuild multi-arch images.
  8. File permission problems — the app cannot read a mounted config or write to a volume running as a non-root user. Check securityContext and volume ownership (fsGroup helps).

Deeper Debugging Techniques to Troubleshoot CrashLoopBackOff in Kubernetes

When logs are not enough, keep the container alive artificially so you can inspect it from inside. Override the entrypoint in a debug copy of the pod:

kubectl run debug-shell --image=myapp:1.0 --restart=Never \
  --command -- sleep 3600
kubectl exec -it debug-shell -- /bin/sh

Inside, you can check environment variables, DNS resolution (nslookup may need installing), mounted files under /etc, and whether the app’s binary runs at all. For image-level forensics, kubectl debug can attach an ephemeral container with proper tooling to the crashing pod.

Also widen your view: kubectl get events --sort-by=.metadata.creationTimestamp across the namespace reveals patterns — for example, several pods failing at once usually means a shared dependency (database, storage class, node) rather than eight independent bugs. The full command set lives in our kubectl commands cheat sheet.

Conclusion

To troubleshoot CrashLoopBackOff in Kubernetes, resist the urge to delete and recreate the pod repeatedly: describe it, read the --previous logs, decode the exit code, and match the symptom against the common-cause checklist — configuration, memory limits, probes, entrypoints, dependencies. In the vast majority of cases the root cause is visible within five minutes using exactly that sequence. The official Kubernetes debugging documentation covers the advanced tools, including debug containers and node-level investigation, when the standard workflow is not enough.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.