Skip to content

Troubleshooting guide

Kubernetes CrashLoopBackOff: how to fix it

CrashLoopBackOff means a container keeps exiting and Kubernetes is waiting longer and longer before restarting it. The answer is in the last crash’s logs and exit code.

3 min read10 sectionsUpdated

On this page

Key points

  • It is a symptom, not a cause: the container starts, exits, and restarts with back-off.
  • Read the previous container’s logs: the current one may have no output yet.
  • The exit code narrows it down: 1 is an app error, 137 is a kill (often OOM), 143 is SIGTERM.
  • Liveness probes that are too strict can cause the loop on a healthy app.

Gather the facts

bash
kubectl get pods -n prod
kubectl describe pod <pod> -n prod          # Last State, Reason, Exit Code, Events
kubectl logs <pod> -n prod --previous       # logs from the crashed container
kubectl logs <pod> -n prod -c <container> --previous   # multi-container pods
kubectl get events -n prod --sort-by=.lastTimestamp | tail -n 20

Exit codes

Exit codeMeaningLook at
0Exited successfully, but a Deployment expects it to keep runningCommand finishes instead of serving; wrong entrypoint
1Application errorLogs: missing config, failed connection, exception on start
126 / 127Command not executable / not foundImage, entrypoint, PATH
137Killed by SIGKILLOOMKilled in Last State; or liveness probe failure
139Segmentation faultNative modules, base image mismatch
143SIGTERMProbe failures or the container being stopped

The usual causes

  • Missing environment variables or secrets: the app throws on start. Check envFrom, secret names and keys.
  • Cannot reach a dependency at startup: database or cache not ready. Retry with backoff instead of exiting.
  • Liveness probe too aggressive: the app needs 40 s to start, the probe kills it at 10 s. Use a startupProbe, or raise initialDelaySeconds and failureThreshold.
  • Out of memory: Reason OOMKilled. Raise the limit or fix the leak; see OOMKilled.
  • Wrong image or architecture: an arm64 image on amd64 nodes, or a bad tag.
  • File permission problems with read-only root filesystems or non-root users.

A safer probe setup

deployment.yamlyaml
startupProbe:
  httpGet: { path: /health/live, port: 8080 }
  periodSeconds: 5
  failureThreshold: 30        # up to 150 s to start
livenessProbe:
  httpGet: { path: /health/live, port: 8080 }
  periodSeconds: 10
  failureThreshold: 3
readinessProbe:
  httpGet: { path: /health/ready, port: 8080 }
  periodSeconds: 5
  failureThreshold: 2

When logs are empty

If the container dies before logging, override the command to keep it alive and inspect it, or use an ephemeral debug container:

bash
kubectl debug -it <pod> -n prod --image=busybox:1.36 --target=<container>
# or run the image by hand with a shell
kubectl run debug --rm -it --image=<your-image> --command -- sh

Catch restarts early

Alert on restart counts rising, not only on pods being down: a pod that restarts every ten minutes may still pass most uptime checks. VitalRix infrastructure monitoring shows clusters, namespaces, workloads and pods with restart counts, CPU and memory against limits. See the Kubernetes monitoring guide.

Frequently asked questions

How long is the CrashLoopBackOff delay?

Kubernetes doubles the wait between restarts, starting at 10 seconds and capped at 5 minutes, and resets it after the container runs successfully for 10 minutes.

Does deleting the pod fix it?

Only if the cause was transient. The Deployment creates a new pod with the same spec, which usually crashes the same way.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.