CrashLoopBackOff means a container in your Pod keeps starting, exiting and being restarted, and the kubelet is now waiting before the next restart attempt. It isn't the root cause. It's Kubernetes telling you to go look at why the container exits. To fix a CrashLoopBackOff, read the previous container's logs (kubectl logs <pod> --previous), check the exit code and reason in kubectl describe pod, and match them against the common causes below: bad command, missing config, OOM kills, failing liveness probes, permissions, wrong CPU architecture or an unavailable dependency.

This guide gives you a repeatable debugging flow with exact commands, a cause-and-fix table, and the settings that keep crash loops from coming back. Commands are written for current kubectl and Kubernetes 1.35+ clusters, and backoff details are taken from the official Pod lifecycle documentation.

What CrashLoopBackOff actually means

When a container exits and the Pod's restartPolicy allows a restart (Always, the only value Deployments allow, or OnFailure with a non-zero exit), the kubelet restarts it in place on the same node. After the first crash it applies an exponential backoff: 10s, 20s, 40s and so on, capped at 300 seconds (5 minutes). If the container then runs for 10 minutes without problems, the kubelet resets the backoff timer. While the kubelet is waiting, the container's state is Waiting with reason CrashLoopBackOff, and that's what kubectl get pods shows in the STATUS column.

Two consequences trip people up:

  • The Pod isn't rescheduled. The same Pod restarts on the same node, so moving it doesn't help unless the cause is node-specific.
  • A clean exit still loops. With restartPolicy: Always, a container that exits with code 0 is restarted too. A one-shot script packaged as a Deployment will crash-loop even though nothing "failed".

Backoff tuning in recent Kubernetes releases

The 5-minute cap makes iteration painful, and SIG Node has been working on it:

Feature gate Status Effect
KubeletCrashLoopBackOffMax Beta since 1.35, on by default Per-node max delay via kubelet config crashLoopBackOff.maxContainerRestartPeriod, from "1s" to "300s" (KEP-5593)
ReduceDefaultCrashLoopBackOffDecay Alpha since 1.33, off by default Cluster-wide defaults become 1s initial and 60s max (KEP-4603)

For a dev or CI node pool where fast retries help more than they hurt, set this in the kubelet configuration:

kind: KubeletConfiguration
crashLoopBackOff:
  maxContainerRestartPeriod: "30s"   # delays: 10s, 20s, 30s, 30s, ...

Don't do this in production without thinking about load. Backoff exists so that hundreds of crashing containers don't hammer the API server, registries and downstream services.

Step-by-step: how to debug CrashLoopBackOff

Work through these in order. Most crash loops are solved by step 3.

Step 1: Confirm the state and restart count

kubectl get pods -n shop -o wide
kubectl get pod api-7d9f8c6b5-x2k4q -n shop -w

A rising RESTARTS count with STATUS flipping between Running, Error and CrashLoopBackOff confirms a crash loop. Different statuses point to different problems: ImagePullBackOff is a registry or image-name issue, CreateContainerConfigError usually means a referenced ConfigMap or Secret (or a key in one) doesn't exist, and Pending is a scheduling problem. None of those are crash loops, because the container never started.

Step 2: Read the last termination state and events

kubectl describe pod api-7d9f8c6b5-x2k4q -n shop

Look at two parts of the output:

  • Containers > Last State: Terminated, with Reason (Error, OOMKilled, Completed, StartError) and Exit Code
  • Events at the bottom: Back-off restarting failed container, Liveness probe failed, Startup probe failed or mount errors

To get just the termination details, which is handy in scripts:

kubectl get pod api-7d9f8c6b5-x2k4q -n shop \
  -o jsonpath='{range .status.containerStatuses[*]}{.name}{"\t"}{.restartCount}{"\t"}{.lastState.terminated.reason}{"\t"}{.lastState.terminated.exitCode}{"\n"}{end}'

Events for a namespace, newest last:

kubectl get events -n shop --sort-by=.lastTimestamp
kubectl get events -n shop --field-selector involvedObject.name=api-7d9f8c6b5-x2k4q

Events expire (one hour by default on most clusters), so capture them early in an incident.

Step 3: Read the logs from the crashed container

The current container may have just restarted and printed nothing useful. The previous instance is the one that crashed:

kubectl logs api-7d9f8c6b5-x2k4q -n shop -c api --previous
kubectl logs deploy/api -n shop --all-containers --previous --tail=100

If --previous is empty, the process died before writing anything. That points to the command, entrypoint, architecture or permissions, not to application logic.

Step 4: Decode the exit code

Exit code Meaning Typical cause
0 Process finished successfully One-shot task run under restartPolicy: Always, or a server that daemonizes and returns
1 Generic application error Unhandled exception, bad config, failed DB connection at startup
2 Misuse of shell builtin / bad CLI args (by convention) Wrong flags in args
126 Command found but not executable Missing +x, wrong permissions, noexec mount
127 Command not found Typo in command, binary not in image or not on PATH
137 Killed by SIGKILL (128 + 9) OOMKilled if Reason says so. Otherwise killed after grace period (for example, liveness failure on an app that ignores SIGTERM)
139 Segmentation fault, SIGSEGV (128 + 11) Native crash, incompatible libc or binary
143 Terminated by SIGTERM (128 + 15) Kubelet stopped it, usually after a failed liveness probe, and the app exited on SIGTERM

Codes above 128 mean "128 + signal number". Always pair the code with the Reason field. 137 with OOMKilled is a memory limit problem, while 137 after Liveness probe failed events is a probe or shutdown-handling problem.

Step 5: Get a shell with kubectl debug

When logs don't explain it, inspect the container's environment. A crash-looping container usually doesn't live long enough for kubectl exec, so use kubectl debug.

Copy the Pod and replace the crashing command with a shell, keeping the same image, env, volumes and service account:

kubectl debug api-7d9f8c6b5-x2k4q -n shop -it \
  --copy-to=api-debug --container=api -- sh

Inside, run the real entrypoint by hand, check env, ls -l the config mounts and test connectivity to dependencies. You must pass --container, otherwise kubectl debug adds a new container instead of changing the existing one's command. If the image has no shell (distroless), add a debug container that shares the process namespace:

kubectl debug api-7d9f8c6b5-x2k4q -n shop -it \
  --image=busybox:1.36 --share-processes --copy-to=api-debug

Attach an ephemeral container to the live Pod, useful when the container stays up long enough between crashes:

kubectl debug -it api-7d9f8c6b5-x2k4q -n shop --image=busybox:1.36 --target=api

Go to the node for kubelet and runtime logs:

kubectl debug node/ip-10-0-3-17.ec2.internal -it --image=ubuntu --profile=sysadmin
# the node's filesystem is mounted at /host

Delete debug copies when you're done (kubectl delete pod api-debug -n shop). They aren't managed by the Deployment and will hang around.

Common CrashLoopBackOff causes and fixes

Cause Symptoms Fix
Wrong command/args Exit 127 or 126, empty --previous logs Check the image's ENTRYPOINT/CMD. Remember command overrides ENTRYPOINT and args overrides CMD
Missing or wrong config Exit 1, log says "missing env var" or "cannot parse config" Check ConfigMap/Secret keys and values. Mount paths must match what the app reads
Failing liveness probe Events: Liveness probe failed, exit 143 or 137 Add a startupProbe, fix the probe path or port, increase timeoutSeconds
Out of memory Reason OOMKilled, exit 137 Raise the memory limit, fix the leak, set runtime heap limits (JVM, Node.js)
Permissions permission denied in logs, exit 1 or 126 Fix runAsUser/fsGroup, write to an emptyDir instead of a read-only root FS
Wrong CPU architecture exec format error, often no other logs Build multi-arch images or pin the node architecture
Dependency not ready Connection refused or DNS errors at startup, exit 1 Retry with backoff in the app, or gate startup with an init container
Process exits cleanly Reason Completed, exit 0 Use a Job/CronJob, or run the server in the foreground

Bad command or entrypoint

Compare what the image runs with what the Pod overrides. If command: ["python"] with args: ["app.py"] runs from the wrong working directory, you'll get exit 2 and a "can't open file" message. Test the exact command locally with docker run --entrypoint before changing manifests.

Missing or malformed configuration

If a referenced Secret or ConfigMap is missing entirely, you'll usually see CreateContainerConfigError, not a crash loop. A crash loop happens when the object exists but a value is wrong: a typo in a URL, a trailing newline in a password, a base64 value encoded twice. Read what the Pod actually sees:

kubectl get secret api-db -n shop -o jsonpath='{.data.DATABASE_URL}' | base64 -d; echo

If you're staring at an encoded blob in a manifest, a Base64 encoder/decoder makes double-encoding and stray newlines obvious. Don't paste production credentials into any web tool, though. Decode real secrets locally.

Liveness probe kills a slow-starting app

A liveness probe with initialDelaySeconds: 10 on an app that needs 45 seconds to warm up guarantees a crash loop. The fix is a startupProbe. Liveness and readiness checks don't run until it succeeds:

containers:
  - name: api
    image: registry.example.com/api:2.3.1
    ports:
      - containerPort: 8080
    startupProbe:
      httpGet:
        path: /healthz
        port: 8080
      periodSeconds: 5
      failureThreshold: 30      # allows up to 150s to start
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      periodSeconds: 10
      timeoutSeconds: 2
      failureThreshold: 3
    readinessProbe:
      httpGet:
        path: /ready
        port: 8080
      periodSeconds: 5

Keep liveness checks cheap and local. A liveness endpoint that queries the database turns a database blip into a cluster-wide restart storm. Put dependency checks in readiness instead.

OOMKilled

Reason: OOMKilled with exit 137 means the container exceeded its memory limit and the kernel killed it (our OOMKilled exit code 137 guide goes deeper). Check actual usage with kubectl top pod, then either raise resources.limits.memory or make the runtime respect the limit. JVMs need container-aware heap sizing such as -XX:MaxRAMPercentage=75, and Node.js may need --max-old-space-size. On clusters with in-place resize, you can raise limits without recreating the Pod. See our Kubernetes in-place Pod resize guide.

Permissions and read-only filesystems

Hardened Pods (runAsNonRoot, readOnlyRootFilesystem: true) often crash on first deploy because the app writes a PID file, cache or temp file to the image filesystem. Mount an emptyDir at the path it needs (/tmp, /var/run, /app/cache), and set fsGroup so mounted volumes are writable by the container's group.

Image architecture mismatch (exec format error)

An amd64-only image scheduled on an arm64 node (Graviton, Ampere, Apple-silicon-built images going the other way) fails immediately with exec format error. Check both sides:

kubectl get nodes -L kubernetes.io/arch
docker buildx imagetools inspect registry.example.com/api:2.3.1

Fix it by publishing a multi-arch image (docker buildx build --platform linux/amd64,linux/arm64 ...) or by pinning the workload with nodeSelector: {kubernetes.io/arch: amd64} until you do.

Dependency not ready

Apps that exit when the database, queue or an upstream API isn't reachable at startup crash-loop during every rollout or outage. The robust fix is in the app: retry with jittered backoff instead of exiting. If you can't change the app, gate startup with an init container:

initContainers:
  - name: wait-for-db
    image: busybox:1.36
    command: ["sh", "-c", "until nc -z postgres.shop.svc.cluster.local 5432; do echo waiting; sleep 2; done"]

If DNS resolves but connections time out, check NetworkPolicies. A default-deny policy without an egress rule to the database is a classic cause. Our Cilium vs Calico comparison covers policy tooling that shows dropped flows.

How to prevent CrashLoopBackOff

  • Use startup probes for anything that takes more than a few seconds to boot, and keep liveness probes local and cheap.
  • Set requests and limits from measured usage, not guesses, and leave headroom on memory limits. CPU throttling slows a container down, but exceeding the memory limit kills it.
  • Handle SIGTERM and exit within terminationGracePeriodSeconds, so probe-triggered restarts give exit 143 and a clean log, not a 137 that hides the cause.
  • Use the right workload type. Run tasks that finish as Jobs. Since 1.35, container-level restartPolicy and restartPolicyRules (beta, on by default) let you restart only on specific exit codes.
  • Fail fast on config in CI, not in the cluster. Validate rendered manifests, required env vars and image architectures in your pipeline.
  • Alert on it. With kube-state-metrics, kube_pod_container_status_waiting_reason{reason="CrashLoopBackOff"} > 0 for a few minutes is a good page-worthy signal. Pair it with log search and error tracking so the stack trace is one click away. See our Grafana vs Datadog comparison and Sentry alternatives.

Frequently Asked Questions

How long does Kubernetes wait between CrashLoopBackOff restarts?

By default, the kubelet waits 10 seconds after the first crash and doubles the delay each time (10s, 20s, 40s...), up to 5 minutes. The timer resets after the container runs for 10 minutes without crashing. Since Kubernetes 1.35, admins can lower the per-node maximum with crashLoopBackOff.maxContainerRestartPeriod.

How do I restart a Pod stuck in CrashLoopBackOff?

Fix the cause first, otherwise a restart just resets the loop. After deploying the fix, kubectl rollout restart deployment/<name> replaces the Pods. Deleting a single Pod (kubectl delete pod <name>) lets its controller create a fresh one with a new backoff timer.

Why are my CrashLoopBackOff logs empty?

The current container may not have logged anything yet. Use kubectl logs <pod> --previous to see the crashed instance. If that's empty too, the process failed before your code ran. Check exit code 126/127 (command problems), exec format error (architecture) and the Events section for mount or permission errors.

What is the difference between CrashLoopBackOff and ImagePullBackOff?

ImagePullBackOff means the image never downloaded: wrong name or tag, missing registry credentials, or rate limiting. CrashLoopBackOff means the image was pulled and the container started, but then exited repeatedly. They need different fixes, registry access versus application or configuration; our ImagePullBackOff guide covers the registry side.

Can a liveness probe cause CrashLoopBackOff?

Yes, and it's one of the most common causes. If the probe fails failureThreshold times, the kubelet kills and restarts the container, and repeated kills trigger backoff. Look for Liveness probe failed events, then add a startupProbe or relax the probe's timing.

Conclusion

CrashLoopBackOff is a symptom with a short list of causes. Follow the same path every time: describe for the reason and exit code, logs --previous for the crashed instance, events for probe and mount failures, then kubectl debug --copy-to when you need to look inside. Most crash loops come down to a wrong command, bad config, an aggressive liveness probe or a memory limit, and startup probes, measured resource limits and proper SIGTERM handling prevent most of them.