AWSMid
ECS task stopped: how to find the reason
If an ECS task starts and then disappears, read its stopCode and stoppedReason with describe-tasks, then follow the matching AWS error category.
What you see
- The task shows
PENDINGand then disappears - A service keeps stopping and replacing tasks
What it means
A task can stop because of an application or configuration error. For tasks created by a service, ECS publishes what it does in the service events, including stopping and replacing a task whose containers stopped or failed too many load balancer health checks.
Stopped tasks appear in the console for only 1 hour, so look quickly.
How to confirm the cause
- 1List stopped tasks
aws ecs list-tasks --cluster CLUSTER_NAME --desired-status STOPPED --region REGION
- 2Describe one
aws ecs describe-tasks --cluster CLUSTER_NAME --tasks TASK_ARN --region REGION
Read
stopCode(for exampleResourceInitializationError),stoppedReason, andreasoninside each container.
Causes and fixes
A known error category
- HOW TO TELL
stopCodenames one of: TaskFailedToStart, ResourceInitializationError, ResourceNotFoundException, SpotInterruptionError, InternalError, OutOfMemoryError, ContainerRuntimeError, ContainerRuntimeTimeoutError, CannotStartContainerError, CannotStopContainerError, CannotInspectContainerError, CannotCreateVolumeError, CannotPullContainer.- FIX
- Open the AWS troubleshooting page for that category (linked below) and follow it. Each category has its own page.
How to stop it coming back
- Send container logs to CloudWatch Logs so a stopped task's output survives.
- Alert on service events that show repeated task replacement.
Keep going
- Runbook: Application Load Balancer 502, 503 and 504 errors
- Cheat sheet: AWS CLI
- Lesson: the containers topic in Learn
Sources
AWS documentation (docs.aws.amazon.com), read 18 Nov 2026.