Skip to content

CrashLoopBackOff

CrashLoopBackOff isn’t the error. It means the container started, exited, and the kubelet is now waiting before it restarts it again. The real error is in how the previous container exited.

The wait grows each time: by default it starts at 10 seconds and doubles up to a cap of five minutes, and resets once the container runs for ten minutes without exiting. Newer Kubernetes releases add feature gates to tune this, so check the documentation for your version.

1. How did the last container exit?

Terminal window
kubectl get pod <pod> -o jsonpath='{range .status.containerStatuses[*]}{.name}: {.lastState.terminated.reason} exit={.lastState.terminated.exitCode}{"\n"}{end}'

The exit code narrows it down before you read a single log line. See the table below.

2. What did it print before it died?

Terminal window
kubectl logs <pod> --previous
kubectl logs <pod> -c <container> --previous # multi-container pods

Without --previous you get the logs of the current attempt, which is often empty because it just started.

3. What does the kubelet say?

Terminal window
kubectl describe pod <pod>

Look at Last State for the container, and at the events. Repeated Back-off restarting failed container events just confirm the loop. Liveness probe failed followed by failed liveness probe, will be restarted means the kubelet is killing a container that might otherwise be fine.

4. No logs at all? Look inside.

If the container dies before it can log, start a copy of the pod with the command replaced by a shell, so you can inspect the filesystem and environment:

Terminal window
kubectl debug <pod> -it --copy-to=<pod>-debug --container=<container> -- sh

This only works if the image has a shell. For distroless images, attach an ephemeral debug container to the running pod instead (kubectl debug -it <pod> --image=busybox --target=<container>). Delete the copy when you’re done.

Exit code Usually means
0 The process finished successfully, but the pod’s restart policy restarts it anyway. A batch script is running as a Deployment. Use a Job.
1 The application failed on startup: missing config or environment variable, failed database connection, bad flag. Read the logs.
126 The command exists but isn’t executable. Check file permissions in the image.
127 Command not found: a wrong command or args, or the binary isn’t in the image. Common with distroless and scratch images.
137 Killed with SIGKILL. If the reason is OOMKilled, it exceeded its memory limit. Otherwise something killed it forcibly, often after a liveness failure and the grace period running out.
139 Segmentation fault. A crash in native code or a library mismatch in the image.
143 Exited on SIGTERM. Common when a liveness probe fails and the app shuts down cleanly.

Read next: How a pod gets from YAML to running.