A CrashLoopBackOff means your pod keeps dying shortly after starting. The control plane restarts it, the app fails again, and the cycle repeats. This is one of the most common failures you will hit on a Kubernetes cluster, and it is usually traceable to a few clear causes. Start by checking the pod status, then pull the logs, and inspect recent events. Most loops break because of an application crash, a missing configuration, a resource limit, or a readiness probe that fails. Fix the underlying cause, not just the restart counter.
How to confirm a CrashLoopBackOff
Run kubectl get pods to see the status. The Ready column shows 0/1, and the Restart count climbs. Then use kubectl describe pod <name> to read the events section. Look for lines like Back-off restarting failed container or CrashLoopBackOff. These events point to the restart policy and the reason the container is failing.
Next, pull the logs with kubectl logs <pod> --previous. The --previous flag shows output from the last terminated container, which often holds the actual error message. If the app logs nothing, check the container image, environment variables, and mounted volumes. A missing file, a bad entrypoint, or an incorrect command will exit with a non-zero status and trigger the loop.
Fix 1: Read the logs and the last terminated container
The first step is always the same. Open the logs for the current container and the previous one. Use this command:
kubectl logs <pod-name> --previous
kubectl logs <pod-name> -f
The previous logs usually contain the stack trace or the exit message. If you see exec format error, the binary was built for a different architecture. If you see no such file or directory, a required file or library is missing. If you see permission denied, the entrypoint or script lacks the execute bit. Fix the artifact, rebuild the image, and push the new image.
Fix 2: Check resource limits and requests
A pod can enter a crash loop when it runs out of memory or when the application is killed by the kernel. The OOMKilled status appears in kubectl describe pod. The container gets killed, the restart policy kicks in, and the loop continues. Set explicit requests and limits for CPU and memory. Without limits, a memory-hungry process can exceed the node capacity and get terminated.
Apply a deployment patch or edit the manifest directly. For example, set requests and limits on the container:
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
Then apply the change:
kubectl apply -f deployment.yaml
Watch the pod after the update. Use kubectl get pods -w to watch for a stable Ready state. If the pod stays up, the resource limit was the culprit. If it still crashes, move to the next check.
Fix 3: Verify readiness and liveness probes
A readiness probe can fail if the app is not ready to serve traffic. The pod gets marked NotReady, and traffic is removed from it. A liveness probe can kill the container if the app hangs. Both probes share the same endpoint, but they serve different purposes. The readiness probe checks if the app can accept requests. The liveness probe checks if the app is alive.
If your app needs time to initialize, set an initial delay. A short probe interval with no delay can fail on startup. Use initialDelaySeconds and periodSeconds to give the app time to warm up. For example:
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
Adjust the values based on your startup time. If the probe fails too early, the pod never becomes ready. Test the endpoint manually in the container to confirm it responds as expected.
Fix 4: Inspect events and configuration
Run kubectl get events --sort-by=.lastTimestamp to see recent cluster activity. Look for FailedScheduling, ImagePullBackOff, or OOMKilled events. These events explain why the pod cannot start or why it keeps dying. Check the node status with kubectl get nodes. A full disk, low memory, or a drained node can prevent scheduling or cause restarts.
Also review the deployment spec. Missing environment variables, wrong volume mounts, or an invalid command will cause a quick exit. Use kubectl exec to run a shell inside the container and verify the file system. Check that the entrypoint script has the right permissions and that required files exist.
If you changed the image or the configuration, roll back to the last known good state. Use kubectl rollout undo deployment/<name> to revert the deployment. Then verify the previous revision is running.
How to verify the fix
After applying a fix, watch the pod closely. Use kubectl get pods to confirm the status is Running and Ready. Use kubectl describe pod to check the events. The restart count should stay flat after the first start. If the pod keeps restarting, the root cause is still present.
Check the logs again. The application should stay up and produce output. If the logs show a crash, identify the new error and fix it. If the logs are empty, check the entrypoint and the working directory. A missing file or a wrong path will cause the container to exit silently.
Monitor the node resources. If the node is under pressure, the pod may be killed even with limits set. Use kubectl top nodes to check resource usage. If the node is full, clean up unused images, pods, or volumes. A full disk will prevent the kubelet from writing logs and can cause the node to become unschedulable.
Common pitfalls to avoid
Do not just raise the restart policy. The default is Always, and changing it to Never or OnFailure hides the problem. The pod will stop restarting, but the application will not serve traffic. Fix the cause instead.
Do not ignore the events section. The events often contain the exact error message. A FailedScheduling event means the pod cannot fit on any node. An ImagePullBackOff means the image cannot be pulled. An OOMKilled event means the container exceeded memory.
Do not assume the issue is in your code. Check the image, the node, and the configuration. A bad image tag, a wrong volume path, or a misconfigured probe can all cause the same loop.
What to check first
Start with the pod status and the events. Read the logs from the previous container. Check the resource limits and the probe configuration. Verify the image and the entrypoint. Then apply the fix and watch the pod until it stays stable. If the problem persists, roll back to the last known good state and investigate further.
