Skip to content

Fix Kubernetes CrashLoopBackOff

Short answer: CrashLoopBackOff means a container starts, exits, and Kubernetes keeps restarting it with an increasing back-off delay. Find out why it exits with kubectl logs <pod> --previous and kubectl describe pod <pod>, then fix the cause — a bad command, missing config/secret, failed dependency, or an OOM kill. The pod recovers once the container can start and stay up.

Last reviewed: 2026-06-27.

Diagnose it (3 commands)

kubectl get pod <pod> -n <ns>                 # confirm CrashLoopBackOff + restart count
kubectl logs <pod> -n <ns> --previous         # logs from the crashed container (the key step)
kubectl describe pod <pod> -n <ns>            # events + last state / exit code + reason

The previous logs are what matter — the current container may not have started yet.

Common causes & fixes

Cause Signal Fix
App exits non-zero on start stack trace / exit 1 in --previous logs fix the bug, env var, or entrypoint; roll out
Missing config / secret "file not found", "env X required" mount the ConfigMap/Secret; check keys
Failing dependency at boot "connection refused" to DB/cache fix the dependency or add a readiness/startup probe + retry
OOMKilled Reason: OOMKilled, exit 137 raise the memory limit — see OOMKilled
Bad liveness probe killed before it's ready loosen initialDelaySeconds / use a startup probe
Wrong image entrypoint/command "exec format error", "not found" fix command/args or the image

Fix on the controller, not the pod

Pod specs are immutable — patch the Deployment/StatefulSet/DaemonSet so the fix survives the restart:

kubectl set resources deploy/<name> --limits=memory=512Mi -n <ns>   # for OOM
kubectl rollout restart deploy/<name> -n <ns>                       # re-pull config
kubectl set image deploy/<name> app=<repo>:<good-tag> -n <ns>       # bad image

How Karakuri fixes it for you

Karakuri is an open-source Kubernetes auto-remediation Slack bot. When a pod crashloops it:

  1. Detects the restart in real time (no Prometheus), pulls the --previous logs and events.
  2. Uses an LLM to identify the root cause and posts a Slack card with a one-click, guard-railed kubectl fix (dry-run preview + signed confirm + audit).
  3. Applies the fix, then verifies the workload recovered — and re-investigates if not.

Try it with no Slack and no API key: make demo spins a kind cluster + a crashloop pod and shows the loop in your terminal.

FAQ

What's the difference between CrashLoopBackOff and Error? Error is a single failed start; CrashLoopBackOff is Kubernetes backing off after repeated failures (the restart delay grows up to 5 minutes).

Why do I need --previous? The current container may be waiting in back-off and have no logs yet — --previous shows the run that actually crashed.

Can it auto-resolve falsely? A crash that stops restarting isn't necessarily fixed. Karakuri verifies the controller actually rolled out healthy before marking it resolved.