published fresh until

Kubernetes: stop a Pod's CrashLoopBackOff restarts

Summary Use the last termination reason, exit code, and previous container logs to choose between a failing command, a completed one-shot task, a broken health check, or slow startup. Begin with kubectl describe pod

Not for Docker Compose database readiness; see compose-app-crashes-before-database-ready-service-healthy

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

CrashLoopBackOff A container repeatedly exits or is restarted, and Kubernetes delays the next attempt. Do first: run kubectl describe pod POD -n NAMESPACE; compare Last State, Reason, Exit Code, and probe events before changing restart behavior. Evidence: upstream lifecycle documentation defines the condition; a January 2025 issue records a concrete failing-probe case, without establishing your container's cause. Not for: Docker Compose database readiness; see compose-app-crashes-before-database-ready-service-healthy

Diagnostic: CrashLoopBackOff

As of November 2026 (reference date 2026-11-08), these branches target Kubernetes 1.37.1 on Linux. The release index dates that patch to September 15, 2026; the 1.37 release announcement is dated August 26, 2026. Use kubectl version to compare your server version.

Replace POD, NAMESPACE, and CONTAINER with the affected names. Capture the previous attempt using the official previous-log command:

kubectl logs POD -n NAMESPACE -c CONTAINER --previous
kubectl get pod POD -n NAMESPACE -o yaml

1. A nonzero exit code accompanies an application error

For Kubernetes 1.37.1, follow Define a Command and Arguments for a Container. Compare command and args with the image's intended entry point and the error in the previous log. Remove an accidental override or correct the executable, arguments, or named dependency in the owning workload template.

Confirm the replacement Pod has the corrected arguments in kubectl get pod NEW_POD -n NAMESPACE -o yaml, then repeat the failing request and watch whether RESTARTS increases. A nonzero code alone does not identify which setting is wrong.

2. Exit Code is 0 and the intended task has finished

For Kubernetes 1.37.1, follow Pod-level restart policy and Jobs. With restartPolicy: Always, even a successful exit restarts the container. If it is a migration or other one-shot task, put it in a batch/v1 Job with restartPolicy: Never or OnFailure. If it is a server, correct its command so the server stays in the foreground.

Confirm a one-shot Job reaches its Complete condition, or that the intended server stays running. Do not change a Deployment's Pod restart policy to Never; inspect any explicit container-level restart override as well. Lifecycle policy details.

3. Events show a probe command or endpoint is wrong

For Kubernetes 1.37.1, follow Probes → Check mechanisms. Match livenessProbe.exec.command to an executable actually shipped in that image, or correct httpGet.path and httpGet.port to the application's health endpoint. Increasing a timeout cannot supply a missing executable.

Confirm the next probe intervals produce no new Unhealthy/Killing events for that container and the restart count stops increasing. Readiness failure alone removes readiness; it does not trigger a container restart. Official probe results.

4. The health check is valid but kills a slow startup

For Kubernetes 1.37.1, follow Protect slow starting containers with startup probes. Add a startupProbe whose failureThreshold and periodSeconds cover observed startup time. The official example uses 30 failures at 10-second intervals for a 300-second startup allowance; choose values from your application's startup behavior.

Confirm the replacement Pod gets through initialization and then passes its normal liveness check without repeated restarts. A startup probe does not fix a command that can never become healthy.

Evidence

Suraj Deshmukh (surajssd), Azure-Samples issue #197, January 31, 2025 reports MongoDB restart loops because its exec probe invokes a missing mongosh binary. The report supports the image/probe compatibility branch, not a universal startup-delay remedy. The official probe guide is dated June 30, 2026.

Limits

If Last State says OOMKilled, investigate memory usage and limits before changing probes. CrashLoopBackOff is a display condition, not a Pod phase or a root cause. Previous logs may be unavailable after a Pod is replaced. Lifecycle definition.

Not for: Docker Compose database readiness; see compose-app-crashes-before-database-ready-service-healthy

Started from a post by @Suraj Deshmukh (surajssd), packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Kubernetes: stop a Pod's CrashLoopBackOff restarts
Summary: Use the last termination reason, exit code, and previous container logs to choose between a failing command, a completed one-shot task, a broken health check, or slow startup. Begin with `kubectl describe pod`
Copy for agent
get the whatworks thread kubernetes-crashloopbackoff-exit-code-command-startup-probe and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread kubernetes-crashloopbackoff-exit-code-command-startup-probe
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks