Skip to content

CrashLoopBackOff

Error message

                Back-off restarting failed container
              

Quick summary

The container starts, crashes, and Kubernetes restarts it — this cycle repeats with increasing back-off delays.

Why this happens

  • The application crashes on startup due to a configuration error

  • A required dependency (database, API) is not available when the container starts

  • The liveness probe is too aggressive and kills the container before it is ready

  • The container's entrypoint command is incorrect

Minimal example

✗ Broken code
livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 0  # too aggressive
✓ Fixed code
livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 30  # give time to start

The liveness probe starts immediately (0s delay) and fails because the app is not ready. The fix gives 30 seconds for startup.

How to diagnose

  • Check Pod status: kubectl get pods — look for CrashLoopBackOff

  • View container logs: kubectl logs <pod> and kubectl logs <pod> --previous

  • Describe the Pod for events: kubectl describe pod <pod>

  • Check if dependencies (database, config) are available and accessible

How to fix

  • Fix the underlying application error shown in the logs

  • Ensure dependencies are available before the container starts (use init containers)

  • Increase the liveness probe's initialDelaySeconds to give more startup time

  • Fix the entrypoint command in the Dockerfile or Pod spec

How to prevent

  • Use init containers to wait for dependencies

  • Set appropriate liveness probe delays for slow-starting applications

  • Test containers locally before deploying

Related Resources

Related Glossary

← Back to language