CrashLoopBackOff
KubernetesERRORCommonPod LifecycleHIGH confidence

Container keeps crashing and restarting

What this means

A pod is stuck in a crash loop. Kubernetes starts the container, it terminates, and Kubernetes repeatedly tries to restart it with an increasing backoff delay.

Why it happens
  1. 1Application exits immediately due to a fatal startup error
  2. 2Missing required environment variable or ConfigMap key
  3. 3Liveness probe fails repeatedly causing forced restarts
  4. 4Incorrect command or arguments in the container spec
How to reproduce

A pod starts, crashes within seconds, and Kubernetes applies exponential backoff before restarting.

trigger — this will error
trigger — this will error
kubectl get pods

expected output

NAME     READY   STATUS             RESTARTS   AGE
mypod    0/1     CrashLoopBackOff   5          3m

Fix 1

Inspect the previous container logs

WHEN To understand why the container exited

Inspect the previous container logs
kubectl logs mypod --previous --tail=50

Why this works

The --previous flag shows logs from the terminated container before the current restart.

Fix 2

Check environment variables and mounted configuration

WHEN When the app fails due to missing configuration

Check environment variables and mounted configuration
kubectl describe pod mypod

Why this works

Describe shows events and env bindings, which can reveal missing references that cause container exit.

Fix 3

Exec into a running container for debugging

WHEN If the container runs long enough before crashing

Exec into a running container for debugging
kubectl exec -it mypod -- /bin/sh

Why this works

Provides an interactive shell to check file paths, network connectivity, and application state.

What not to do

Set restartPolicy: Never to stop the crash loop

This hides the root cause. You should fix the underlying application error instead.

Sources
Official documentation ↗

k8s.io/api/core/v1 — ContainerState

Debug Running Pods

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Kubernetes errors