ECS Task Failures and Restarts

Identify why ECS tasks stop unexpectedly and prevent restart loops from impacting availability.

Overview

Overview

ECS task failures fall into a few distinct categories, each with its own signal and fix. The first step is always the stopped task reason in the ECS console or CLI: ECS keeps it for a while after the task stops, and it narrows the problem immediately.

When a task stops, its reason points to one of four places. A CannotPullContainerError means the task never got its image. Exit code 137 means the container was OOMKilled. A task marked unhealthy failed a health check, either the ECS check or the ALB check. And 'Essential container exited' means a sidecar or the app itself quit and took the task down with it.

Key concepts

  • Stopped Task Reason
  • OOMKilled (Exit Code 137)
  • startPeriod
  • Essential Container
  • Deployment Circuit Breaker

Interview questions

  • An ECS service is stuck in a restart loop. Tasks start, run for 30 seconds, then stop, and new tasks immediately replace them. How do you diagnose this systematically?
  • How does ECS health checking interact with ALB health checking, and how do misconfigured thresholds create phantom restart loops?

Sign up free to read the full topic

More Troubleshooting topics

Start free on Cariara · Coding problems · System design studio