Kubernetes CrashLoopBackOff: find why a container keeps restarting
CrashLoopBackOff
CrashLoopBackOff means Kubernetes is delaying another restart after a container has repeatedly exited or been killed. It is a container waiting reason shown by kubectl, not a Pod phase or a diagnosis of the application failure. Find the termination reason and the previous container's logs before changing restart settings.
The main application process exits because of an invalid argument, missing runtime configuration, failed dependency connection, or an application exception.
A liveness or startup probe kills the container before it can become healthy, especially when initialization takes longer than the configured allowance.
The container is terminated by an out-of-memory condition. The restart delay is only the visible consequence; OOMKilled identifies the more specific problem.
A short-lived command finishes successfully but runs in a workload whose restart policy expects a continuously running service.
How to fix it
Run kubectl describe pod POD -n NAMESPACE and identify the affected container, its Last State, exit code, restart count, and recent Events. Replace the uppercase placeholders with actual names. In a multi-container Pod, do not assume the application container is the one restarting.
Read kubectl logs POD -n NAMESPACE -c CONTAINER --previous, then compare current logs without --previous. The previous instance often contains the startup exception that disappears during rapid restarts. If no previous instance is available, collect the next failure and inspect termination details.
Follow the evidence: correct application arguments or configuration for an exception, investigate memory usage for OOMKilled, and review probe events when Kubernetes initiated the restart. An exit code of zero can instead mean the image runs a one-off command that belongs in a Job.
Change the owning Deployment, StatefulSet, or other workload template rather than repeatedly editing or deleting an individual managed Pod. Compare the failing image and configuration with the last working revision, and use the normal rollout or rollback process after assessing compatibility.
Watch the replacement Pod long enough to cover startup and normal traffic. Confirm readiness and a stable restart count. A temporary Running status between failures is not recovery, and shortening backoff only repeats the same failure faster.