DEV Community

kkkevin
kkkevin

Posted on Originally published at opshubs.space

Kubernetes CrashLoopBackOff: Top 6 Causes & 30-Second Fix Checklist

CrashLoopBackOff is not an error itself—it is Kubernetes telling you that a container inside your Pod keeps starting, crashing, and waiting for an exponential backoff delay (10s, 20s, 40s, up to 5 minutes) before restarting again.

30-Second kubectl Diagnosis

Skip guessing and run these three commands in order to capture the exact exit code and crash logs before the container restarts again:

# 1. Check Last State & Exit Code (look for Reason: OOMKilled or Error)
kubectl describe pod  -n 

# 2. Fetch logs from the PREVIOUS crashed container instance
kubectl logs  -n  --previous --tail=100

# 3. Check cluster-level events sorted by time
kubectl get events -n  --sort-by='.lastTimestamp'
Enter fullscreen mode Exit fullscreen mode

Top 6 Root Causes & Exact Fixes

  • Exit Code 137 (OOMKilled): The container exceeded its memory limit. Increase resources.limits.memory or tune JVM/runtime heap using our JVM Container Memory Calculator.

  • Exit Code 1 (Application Error): Missing environment variable, bad database connection string, or invalid config file. Check --previous logs and verify ConfigMaps/Secrets.

  • Aggressive livenessProbe: Your app takes 45s to warm up, but livenessProbe kills it at 15s. Move slow startup checks to startupProbe with a higher failureThreshold.

  • Exit Code 127 / 126 (Entrypoint / Permission Error): Wrong binary path in command, missing executable bit, or readOnlyRootFilesystem: true blocking temp file writes without an emptyDir volume.

  • Missing Dependency on Boot: App crashes immediately if Redis/DB isn't reachable yet. Add an initContainer wait check or implement startup retry logic.

  • Broken Volume Mount Permissions: Running as non-root (runAsUser: 1000) while mounting a root-owned PVC; fix with securityContext.fsGroup.

Production Probe Fix Pattern

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 30
  periodSeconds: 5
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 10
  failureThreshold: 3
Enter fullscreen mode Exit fullscreen mode

Next step: Verify your Pod's memory limits and eviction protection with our free Kubernetes QoS Class Checker.

Originally published at OpsHubs. Found it useful? Buy us a coffee ☕.

Top comments (0)