Application Crash
The application starts and then exits because of an application error, invalid configuration, missing dependency, or runtime exception.
Learn what CrashLoopBackOff means, how to identify the root cause, which kubectl commands to use, and how to troubleshoot a container that repeatedly starts and crashes.
CrashLoopBackOff means Kubernetes has detected that a container is repeatedly starting and then terminating. Kubernetes restarts the container, but after repeated failures it waits progressively longer between restart attempts.
The important point is that CrashLoopBackOff is usually a symptom, not the root cause. The application inside the container is often failing for another reason.
Start by checking the pods in the namespace.
kubectl get podsYou may see something similar to:
NAME READY STATUS RESTARTS
my-app-7d8f9c6b7d-abc12 0/1 CrashLoopBackOff 5The RESTARTS column is especially useful. Repeated restarts indicate that the container is not staying alive.
kubectl describe pod <pod-name>Look at the State, Last State, Exit Code, and Events sections.
Application logs are often the fastest way to identify why the container is exiting.
kubectl logs <pod-name>If the container crashes too quickly, inspect the logs from the previous container instance:
kubectl logs <pod-name> --previousThis command is particularly important when troubleshooting CrashLoopBackOff.
The application starts and then exits because of an application error, invalid configuration, missing dependency, or runtime exception.
Environment variables, ConfigMaps, Secrets, command arguments, or configuration files may contain incorrect values.
Incorrect liveness or startup probes can cause Kubernetes to restart an otherwise running container.
The application may require variables that were not provided through the Deployment, ConfigMap, or Secret.
The image may start with a command or argument that does not exist or causes the application to exit immediately.
Memory limits, CPU limits, or other resource constraints can cause containers to terminate unexpectedly.
kubectl get podsStart by checking the pod status and restart count. A high restart count is a common sign that the container is repeatedly failing.
kubectl describe pod <pod-name>Shows container state, restart information, events, probes, image details, mounts, and scheduling information.
kubectl logs <pod-name>Displays logs from the currently running container instance or the most recent container output.
kubectl logs <pod-name> --previousVery useful for CrashLoopBackOff because the previous container may have crashed before you could inspect its logs.
kubectl get events --sort-by=.lastTimestampShows recent Kubernetes events, which can reveal image, scheduling, probe, mount, or resource-related problems.
kubectl get pod <pod-name> -n <namespace>Use the namespace option when the affected pod is not running in the default namespace.
Events can reveal problems that are not obvious from the application logs.
kubectl get events --sort-by=.lastTimestampYou can also inspect events for a specific pod with:
kubectl describe pod <pod-name>kubectl get podskubectl describe pod <pod-name>kubectl logs <pod-name>kubectl logs <pod-name> --previouskubectl get events --sort-by=.lastTimestamp