Skip to content
Visual explainer 4h to learn 4 steps

Failing Pods: CrashLoopBackOff, ImagePullBackOff, Pending

Diagnose a failing Pod from events, logs and describe output in minutes.

By Invicly Tech, , in Kubernetes Administrator (CKA). About 10 minutes to read.

Topic 26 of 33

In short

Most failing Pods reveal the cause in their status, events and logs. CrashLoopBackOff means the container keeps exiting, ImagePullBackOff means the image cannot be pulled, and Pending means the scheduler cannot place the Pod. Read describe output from the bottom up, starting with Events.

Explained simply

When a Pod fails, Kubernetes almost always tells you why. The trick is knowing where to look. The STATUS column in kubectl get pods gives the headline, kubectl describe gives the story, and kubectl logs gives the app's own words.

Think of it as three questions in order. Did the Pod get a node? If not, it is Pending and the scheduler explains why in the events. Did the image download? If not, you see ErrImagePull or ImagePullBackOff. Did the program keep running? If not, you see CrashLoopBackOff and need the logs.

BackOff just means waiting. After each failure Kubernetes waits a bit longer before it tries again: 10 seconds, then 20, then 40, up to 5 minutes. So a Pod in CrashLoopBackOff is not stuck; it is retrying slowly.

Most Pods are created by a Deployment or another controller. If you fix the Pod directly, the controller may replace it with an unfixed copy. Fix the owner instead, and let it roll out a healthy Pod.

Press Play on a diagram to walk through it one step at a time.

MapPod status to cause
Failing Pod
  • Pending
    • Insufficient CPU or memory
    • Taints or node selectors
    • Unbound PVC
  • ImagePullBackOff
    • Typo in image or tag
    • Private registry, no pull secret
  • CrashLoopBackOff
    • App error or bad command
    • Missing env or config
    • Failing liveness probe
  • CreateContainerConfigError
    • Missing ConfigMap or Secret key
  • OOMKilled
    • Memory limit too low
    • Exit code 137
MapWhere each clue lives
Clues about a failing Pod
  • kubectl get pod
    • STATUS headline
    • READY and RESTARTS
  • kubectl describe pod
    • Events at the bottom
    • Last State and Exit Code
    • Probe failures
  • kubectl logs
    • --previous for crashes
    • -c for one container
  • Owner objects
    • describe rs for quota errors
    • rollout status for the Deployment
  • On the node
    • crictl ps -a and crictl logs
    • journalctl -u kubelet

In depth

Exit codes tell you who stopped the container

kubectl describe pod shows Last State: Terminated with a Reason and an Exit Code. 0 means the program finished normally; in a Deployment that still causes restarts, because long-running containers are expected never to exit. 1 (or another small number) is an error from the app itself, so read the logs. 126 means the command could not run (no permission), and 127 means the command was not found in the image.

Codes above 128 mean a signal killed the process: 128 plus the signal number. 137 is SIGKILL, from the OOM killer (Reason OOMKilled) or after a liveness probe failure when the process ignored SIGTERM. 143 is SIGTERM, a normal shutdown request. 139 is a segmentation fault inside the app.

  • kubectl get pod P -o jsonpath='{.status.containerStatuses[0].lastState.terminated}'
  • A wrong command often shows RunContainerError or StartError instead
  • Restart count climbs with every crash; watch it with -w

Reading CrashLoopBackOff causes

kubectl logs POD shows the current attempt, which may be empty because it just started. kubectl logs POD --previous shows the attempt that crashed, which is usually what you want. For multi-container Pods add -c NAME.

If the logs are empty, the program probably died before printing anything: a bad command or args, a missing file, or a missing environment variable. Compare the command in the Pod spec with what the image expects. If describe shows Liveness probe failed events before each restart, the app is fine but the probe is wrong (wrong port or path, or initialDelaySeconds too short for a slow app). A failing readiness probe never restarts a container; it just leaves the Pod at 0/1 Ready and out of the Service.

FlowTriage a CrashLoopBackOff
  1. 1
    describe pod

    Exit code, reason and probe events

  2. 2
    logs --previous

    Output from the crashed attempt

  3. 3
    Check spec

    command, args, env, mounts, probes

  4. 4
    Fix the owner

    kubectl edit or set on the Deployment

  5. 5
    Watch rollout

    New Pod Running, restarts stay at 0

Image pull failures

A pull goes through the kubelet and the container runtime on the node, not through your laptop. The first failure shows ErrImagePull; repeated failures become ImagePullBackOff. The event message tells you which case you are in: not found or manifest unknown means the name or tag is wrong; pull access denied, unauthorized or 401 means the registry needs credentials.

For private registries, create a docker-registry Secret in the Pod's namespace and list it under spec.imagePullSecrets, or attach it to the service account so every Pod using it gets the secret. imagePullPolicy matters too: Always pulls every time, IfNotPresent uses a cached copy (the default unless the tag is latest), and Never only uses images already on the node.

  • kubectl create secret docker-registry regcred --docker-server=REG --docker-username=U --docker-password=P
  • kubectl patch sa default -p '{"imagePullSecrets":[{"name":"regcred"}]}'
  • On the node: sudo crictl pull IMAGE tests the pull directly

Pending, and when to use kubectl debug

A Pending Pod with a FailedScheduling event lists every node and why it was rejected: Insufficient cpu or memory (requests too big), untolerated taint, didn't match node affinity/selector, or unbound PersistentVolumeClaims. A Pending Pod with no events at all usually means the scheduler is not running. If a Deployment shows no Pods at all, the problem is above the Pod: describe the ReplicaSet to find quota or admission errors.

For a running but misbehaving container, kubectl debug -it POD --image=busybox:1.36 --target=CONTAINER adds an ephemeral debug container that shares the process namespace, handy for distroless images with no shell. For a crashing container, kubectl debug POD -it --copy-to=POD-debug --container=CONTAINER -- sh makes a copy with the command replaced by a shell, so you can look around inside the same image.

Learn it in 4 short steps

About 1h each. Track them with a timer in your plan.

  1. 1
    Read Pod events with describe~1h
  2. 2
    Read current and previous container logs~1h
  3. 3
    Fix CrashLoopBackOff causes~1h
  4. 4
    Fix ImagePullBackOff and Pending Pods~1h

Key points

  • kubectl describe pod shows events, exit codes and last state.
  • kubectl logs --previous shows output from the crashed container.
  • Fix the owner (Deployment), not the Pod, or your change is lost.
  • kubectl get events --sort-by=.lastTimestamp shows the recent timeline.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
kubectl get pods -o wide
kubectl describe pod web-7d9c   # read Events at the bottom
kubectl logs web-7d9c --previous
kubectl get pod web-7d9c -o jsonpath='{.status.containerStatuses[0].lastState}'
kubectl get events --sort-by=.lastTimestamp | tail
kubectl edit deployment web   # fix image, command or resources

A typo in the command

Deployment api shows CrashLoopBackOff and empty logs. Step 1: describe shows Exit Code 127 or a StartError with executable file not found. Step 2: print the command from the Deployment; it says pyhton instead of python. Step 3: fix it on the Deployment with a JSON patch. Step 4: watch the rollout finish and the restart count stay at 0.

bash
kubectl get pods -l app=api
kubectl describe pod -l app=api | grep -E 'Reason|Exit Code|Message'
kubectl get deploy api -o jsonpath='{.spec.template.spec.containers[0].command}'; echo
# ["pyhton","app.py"]
kubectl patch deploy api --type=json -p \
  '[{"op":"replace","path":"/spec/template/spec/containers/0/command/0","value":"python"}]'
kubectl rollout status deploy api
kubectl get pods -l app=api

A Pod that is Running but never Ready

Pod web shows 0/1 READY and the Service has no endpoints, but nothing restarts. Step 1: describe shows Readiness probe failed: connection refused on port 8080. Step 2: check which port the app listens on; nginx uses 80. Step 3: fix the probe port in the Deployment. Step 4: the Pod turns 1/1 and the Service gets an endpoint.

bash
kubectl get pod -l app=web           # 0/1 Running, 0 restarts
kubectl describe pod -l app=web | grep -i readiness
# Readiness probe failed: dial tcp 10.244.1.9:8080: connect: connection refused
kubectl edit deploy web               # readinessProbe.httpGet.port: 80
kubectl rollout status deploy web
kubectl get endpointslices -l kubernetes.io/service-name=web

Quick reference

  • Exit 127 = command not found; 137 = SIGKILL (OOM or liveness); 143 = SIGTERM
  • kubectl logs POD --previous -c CONTAINER for the attempt that crashed
  • ErrImagePull then ImagePullBackOff: read the event for not found versus unauthorized
  • Readiness failure = not Ready, no restarts; liveness failure = restarts
  • No Pods for a Deployment at all: kubectl describe rs for quota or admission errors
  • kubectl debug -it POD --image=busybox:1.36 --target=app adds a debug container
  • Crash back-off doubles from 10s up to a 5 minute cap

Common mistakes

  • Reading only current logs of a crash-looping container instead of --previous.
  • Editing the Pod when a Deployment will recreate it unchanged.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A container exits with code 0 again and again in a Deployment. Why does it show CrashLoopBackOff?

Question 2

2An event says pull access denied, repository does not exist or may require authorization. What do you check?

Question 3

3Which command shows the output of the container run that just crashed?

Question 4

4A Pod stays Pending and kubectl describe shows no events at all. Most likely cause?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Create a Pod bad with image nginx:9.9.9 and write the exact waiting reason to /opt/reason.txt.

  2. Exercise 2medium

    Create a Pod that runs busybox with sh -c 'echo starting; exit 3'. Find the exit code and the last log line, then explain the restart count growth.

  3. Exercise 3hard

    A distroless app container misbehaves and has no shell. Inspect its processes and files without restarting it.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

How do I fix CrashLoopBackOff?
Read kubectl logs --previous and the exit code in kubectl describe. The fix is usually in the app config, command, environment, probes or memory limit, and you apply it on the Deployment, not the Pod.
What is the difference between ErrImagePull and ImagePullBackOff?
ErrImagePull is the first failed pull. ImagePullBackOff means it keeps failing and the kubelet is waiting longer between retries. The cause is the same.
Why does my Pod stay Pending?
The scheduler cannot find a node that fits: not enough requested CPU or memory, taints, affinity rules or an unbound PVC. The FailedScheduling event lists the reason for each node.

Go deeper

ShareXLinkedInWhatsApp