The signature and its neighbors#
The task stops with TaskFailedToStart, has no startedAt, and its reason begins CannotPullContainerError followed by a connection that timed out or was canceled. AWS's own example names the registry host and ends with request canceled while waiting for connection; AWS has reworded these messages since, so key on the category and the timeout, not the full line. A private subnet has no direct internet route, so the task reaches ECR either through a NAT gateway or through VPC endpoints. CannotPullContainer task errors · Stopped-task message updates
Two nearby records look similar and take a different guide:
- A
ResourceInitializationErrorthat names Secrets Manager or Systems Manager is the secret retrieval, which can fail on the same subnet for its own endpoint. See ECS secrets startup errors. - A pull reason that says access was denied, or that the image was not found, means the request reached the registry. See image not found.
On Fargate platform version 1.4.0 and later, the image pull travels through the task's own network interface in your VPC, so the task's subnet, route table and security groups decide the path. On EC2, start from the container instance's subnet instead. Fargate platform 1.4.0 networking
Capture the subnet and security groups the task used#
Use a read-only profile and replace the uppercase placeholders. ECS deletes a Fargate task's network interface when the task stops, so read the attachment details soon, and take the configured security groups from the deployment. Task lifecycle · Attachment fields · Deployment fields
aws ecs describe-tasks \
--profile PROFILE --region REGION --cluster CLUSTER --tasks TASK_ARN \
--query 'tasks[].{deployment:startedBy,platform:platformVersion,reason:stoppedReason,eni:attachments[?type==`"ElasticNetworkInterface"`].details}' \
--output json --no-cli-pager
aws ecs describe-services \
--profile PROFILE --region REGION --cluster CLUSTER --services SERVICE \
--query 'services[0].deployments[].{id:id,status:status,subnets:networkConfiguration.awsvpcConfiguration.subnets,groups:networkConfiguration.awsvpcConfiguration.securityGroups,publicIp:networkConfiguration.awsvpcConfiguration.assignPublicIp}' \
--output json --no-cli-pager
Note the subnetId from the attachment details and the security groups of the deployment whose ID matches startedBy.
Read the routes and endpoints the subnet has#
aws ec2 describe-route-tables \
--profile PROFILE --region REGION \
--filters Name=association.subnet-id,Values=SUBNET_ID \
--query 'RouteTables[].{table:RouteTableId,routes:Routes[].{to:DestinationCidrBlock,prefixList:DestinationPrefixListId,nat:NatGatewayId,gateway:GatewayId,state:State}}' \
--output json --no-cli-pager
aws ec2 describe-vpc-endpoints \
--profile PROFILE --region REGION \
--filters Name=vpc-id,Values=VPC_ID \
--query 'VpcEndpoints[].{id:VpcEndpointId,service:ServiceName,type:VpcEndpointType,state:State,privateDns:PrivateDnsEnabled,subnets:SubnetIds,groups:Groups[].GroupId,routeTables:RouteTableIds,policy:PolicyDocument}' \
--output json --no-cli-pager
If the first command returns nothing, the subnet has no explicit association and uses the VPC's main route table; rerun it with Name=association.main,Values=true and Name=vpc-id,Values=VPC_ID. A route in state blackhole points at a target that no longer exists, such as a deleted NAT gateway. Subnet route tables · describe-route-tables · describe-vpc-endpoints
What each path needs#
ECR serves manifests and API calls from its own endpoints and image layers from Amazon S3, so a pull needs a path to both. ECR interface VPC endpoints
| What the subnet has | Pull path | Check next |
|---|---|---|
0.0.0.0/0 to a NAT gateway, state active, no ECR endpoints | Public ECR and S3 endpoints through NAT | The task's security group allows outbound TCP 443; the subnet's network ACL allows the traffic both ways |
0.0.0.0/0 to a NAT gateway in state blackhole, no ECR endpoints | None | The NAT gateway was deleted or replaced; restore the route |
ecr.dkr and ecr.api interface endpoints, and no working NAT route (none, or one in state blackhole) | Private endpoints | Both endpoints are available; both ecr.api and ecr.dkr have private DNS enabled; an S3 gateway endpoint lists this subnet's route table |
Only ecr.dkr, or only ecr.api, and no working NAT route | Incomplete | Fargate 1.4.0 and later need both, plus the S3 gateway endpoint |
| Interface endpoints, no S3 gateway on this route table, and no working NAT route | Manifests resolve, layers cannot download | Add this subnet's route table to the S3 gateway endpoint, or add one |
| Neither a working NAT route nor ECR endpoints | None | The subnet has no way to reach ECR |
The S3 gateway endpoint works through route tables: it appears in describe-route-tables as a route to a prefix list (prefixList) on each associated table. An S3 interface endpoint cannot stand in for it with ECR. For the endpoint path, the interface endpoints' security group must allow inbound TCP 443 from the tasks, and the task's security group must allow outbound 443 to the endpoints. Interface endpoints work with Amazon-provided DNS; a custom DNS server needs forwarding for the private names. ECS interface endpoint considerations · ECR interface VPC endpoints
aws ec2 describe-security-groups \
--profile PROFILE --region REGION --group-ids TASK_SG ENDPOINT_SG \
--query 'SecurityGroups[].{id:GroupId,inbound:IpPermissions[].{proto:IpProtocol,from:FromPort,to:ToPort,cidrs:IpRanges[].CidrIp,groups:UserIdGroupPairs[].GroupId},outbound:IpPermissionsEgress[].{proto:IpProtocol,from:FromPort,to:ToPort,cidrs:IpRanges[].CidrIp,groups:UserIdGroupPairs[].GroupId,prefixLists:PrefixListIds[].PrefixListId}}' \
--output json --no-cli-pager
An outbound rule limited to the S3 prefix list must still allow TCP 443 to the endpoint addresses for ecr.dkr and ecr.api.
Policies return denials#
An endpoint policy, a gateway endpoint policy or a condition on the execution role produces a denial when it blocks the pull. A timeout points back at routes, endpoints, DNS or security groups. If you restrict the S3 gateway endpoint's policy, ECR's documented minimum is s3:GetObject on arn:aws:s3:::prod-REGION-starport-layer-bucket/*, the bucket that holds ECR layers in that Region. If the execution role restricts ECR access with aws:SourceVpce or aws:SourceVpc, AWS notes that ecr:GetAuthorizationToken cannot take those conditions. Read endpoint policies from PolicyDocument in describe-vpc-endpoints. ECR interface VPC endpoints · Execution role conditions
An illustrative incident, two outcomes#
These records are fictional. orders runs on Fargate 1.4.0 in private subnets subnet-0a and subnet-0b. Its tasks fail to start with a pull timeout at 10:00.
- Outcome A. The route table for both subnets shows
0.0.0.0/0tonat-0c1in stateblackhole, and there are no ECR endpoints in the VPC. A cost cleanup at 09:40 deleted the NAT gateway. Restore an outbound route; the release is not involved. - Outcome B. No NAT route exists.
ecr.apiandecr.dkrendpoints areavailablewith private DNS enabled, and their security group allows 443 from the VPC. The S3 gateway endpoint lists only the route table of the older subnets;subnet-0b, added last week, uses a new table. Tasks placed insubnet-0astart, and tasks insubnet-0btime out. Associate the new table with the gateway endpoint.
Outcome B shows why the subnet comes from the failed task's attachment. Service-level reads would show working endpoints and a healthy deployment.
Confirm on the replacement#
A replacement task should show pullStartedAt and pullStoppedAt, then a startedAt. If the service spans several subnets, check replacements from each subnet before closing the incident, since outcome B fails only in one. Task fields
Where this check misleads#
Route tables, endpoints and rules show the configured path, not traffic. VPC Flow Logs for the task's interface, if enabled before the failure, show whether packets left and whether replies came back. A CloudWatch Logs endpoint or NAT path is also needed for awslogs in a VPC without internet access; that failure, like a missing log group, comes after the pull. See the signature table for the other startup categories.
Questions#
Which VPC endpoints does a Fargate task need to pull from ECR without a NAT gateway?
The com.amazonaws.REGION.ecr.dkr and com.amazonaws.REGION.ecr.api interface endpoints and the Amazon S3 gateway endpoint on the task subnet's route table. The task also needs the endpoints' security group to accept TCP 443 from it.
Why do some tasks pull and others time out in the same service?
The tasks run in different subnets with different route tables or endpoint associations. Read the subnet from each failed task's attachment and compare its route table with a subnet where tasks start.
Does an endpoint policy cause a pull timeout?
A policy refusal comes back as a denial. A timeout means a missing route, endpoint, DNS name or security group rule.