Fargate tasks stop with `CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref ... dial tcp 52.x.x.x:443: i/o timeout`.
IntermediateTroubleshootingECS, EKS, ECR and Lambda
Answer
Likely causes → The task runs in a private subnet with no route to ECR: no NAT gateway, and no VPC endpoints for ecr.api, ecr.dkr and S3 (gateway endpoint, because image layers come from S3). Or it is in a public subnet without assignPublicIp=ENABLED.
Diagnose →
aws ecs describe-tasks --cluster prod --tasks <task-arn> --query 'tasks[].[stoppedReason,containers[].reason]'
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0abc --query 'RouteTables[].Routes'
aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=vpc-0abc --query 'VpcEndpoints[].ServiceName'
Fix →
- Add a NAT route, or add the endpoints:
com.amazonaws.us-east-1.ecr.api,ecr.dkr,logs(interface) ands3(gateway) - The endpoint SG must allow 443 from the task SG
Prevent → Ship a standard "private VPC endpoints" module, and test task launches in every new subnet.
More on ECS, EKS, ECR and Lambda
`docker push 111111111111.dkr.ecr.us-east-1.amazonaws.com/api:1.4` fails with `no basic auth credentials` (or `denied: Your authorization token has expired. Reauthenticate and try again.`).Beginner`ResourceInitializationError: unable to pull secrets or registry auth: ... AccessDeniedException: User: arn:aws:sts::111111111111:assumed-role/ecsTaskExecutionRole/... is not authorized to perform: secretsmanager:GetSecretValue`.IntermediateA task stops with `Essential container in task exited`, exit code 137, and reason `OutOfMemoryError: Container killed due to memory usage`.BeginnerThe ECS service event says `service api was unable to place a task because no container instance met all of its requirements. The closest matching container-instance ... has insufficient memory available.`IntermediateAn ECS deployment rolls back automatically, and the event says `deployment failed: tasks failed to start` from the circuit breaker.Advanced`aws ecs execute-command` fails: `The execute command failed because execute command was not enabled when the task was run or the execute command agent isn't running.`Intermediate