Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

An Amazon ECS task stops because it cannot resolve its image

Your error

CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref1 more line it can show

Fix it fast

Most common cause, 1 of 3

The task definition names a tag or repository that is not there

Push the image under the tag the task definition expects, or register a new task definition revision with the correct URI and point the service at it.

Fix
docker push 111122223333.dkr.ecr.us-east-1.amazonaws.com/my-app:v1.4.2
aws ecs update-service --cluster my-cluster --service my-service --task-definition my-app:42
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

CannotPullContainerError with failed to resolve ref means the Amazon ECS task never received its image manifest. The task definition names a missing tag, the digest ECS pinned at deployment was deleted, or the subnet has no route to the registry. Read the container reason with aws ecs describe-tasks, then push the tag, force a new deployment, or open the route.

  • Applies to Amazon ECS on AWS Fargate and EC2 (November 2026), AWS CLI 2.41, Amazon ECR
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print the image and the stop reason for each container of the failed task. Compare that image string, character by character, with what the repository holds. A tag the repository lacks points to cause 1, a tag that exists points to cause 2 or 3.

Run this first
aws ecs describe-tasks --cluster my-cluster --tasks <task-id> --query "tasks[0].containers[].[image, reason]"

Then find the line you see in this list and open its fix:

  1. 1The task definition names a tag or repository that is not theredescribe-images for the exact repository and tag from the task definition returns an error instead of image details
  2. 2ECS still uses a digest that was deleted after the tag movedThe service ran for days, then scale-out or replacement tasks fail, and the digest a running task reports is gone from the repository
  3. 3The task subnet has no route to the registryThe image and tag exist, and the AWS troubleshooting runbook reports a network or VPC endpoint problem for the task

What does the error look like?

  • CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref
  • The task can't pull the image. Check your network configuration

Cause 1 of 3

The task definition names a tag or repository that is not there

You seedescribe-images for the exact repository and tag from the task definition returns an error instead of image details

Check

AWS lists a mismatch between the image in the task definition and the images in the repository as the first reason for failed to resolve ref. Typical slips are a tag the build never pushed, a repository name typo, or an image URI with the wrong account ID or Region.

Check
aws ecr describe-images --repository-name my-app --image-ids imageTag=v1.4.2

Fix

Push the image under the tag the task definition expects, or register a new task definition revision with the correct URI and point the service at it.

Fix
docker push 111122223333.dkr.ecr.us-east-1.amazonaws.com/my-app:v1.4.2
aws ecs update-service --cluster my-cluster --service my-service --task-definition my-app:42

Verify

describe-images returns the tag, and the next task reaches lastStatus RUNNING.

Verify
aws ecs describe-tasks --cluster my-cluster --tasks <new-task-id> --query "tasks[0].lastStatus"

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 2 of 3

ECS still uses a digest that was deleted after the tag moved

You seeThe service ran for days, then scale-out or replacement tasks fail, and the digest a running task reports is gone from the repository

Check

ECS turns each image tag into a digest when a deployment starts, and every later task in that deployment, including scale-out tasks, starts from the stored digest. Once someone pushes a new image to the same tag and the old image is removed, new tasks ask for a manifest that no longer exists.

Check
aws ecs describe-tasks --cluster my-cluster --tasks <running-task-id> --query "tasks[0].containers[].imageDigest"
aws ecr describe-images --repository-name my-app --image-ids imageDigest=sha256:<digest-from-above>

Fix

Force a new deployment so ECS resolves the tag again and records the current digest. For the long run, give each build its own version tag instead of reusing :latest, as AWS recommends for this error.

Fix
aws ecs update-service --cluster my-cluster --service my-service --force-new-deployment

Verify

Tasks from the new deployment report a digest that describe-images can find, and scale-out tasks start.

Verify
aws ecs describe-tasks --cluster my-cluster --tasks <new-task-id> --query "tasks[0].containers[].imageDigest"

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 3 of 3

The task subnet has no route to the registry

You seeThe image and tag exist, and the AWS troubleshooting runbook reports a network or VPC endpoint problem for the task

Check

A task that cannot reach the registry over HTTPS also fails at the manifest step. Common gaps are a public subnet task launched with public IP disabled, a private subnet with no NAT gateway route, missing Amazon ECR or Amazon S3 endpoints, or security group and network ACL rules that block port 443. AWS ships a runbook that tests these paths for a failed task.

Check
aws ssm start-automation-execution --document-name AWSSupport-TroubleshootECSTaskFailedToStart --parameters '{"ClusterName":["my-cluster"],"TaskId":["<task-id>"]}'

Fix

Match the fix to the subnet. In a public subnet, turn on public IP assignment for the service. In a private subnet, send 0.0.0.0/0 through a NAT gateway in the route table, or create Amazon ECR interface endpoints and the Amazon S3 endpoint with private DNS enabled.

Fix
# public subnet: give tasks a public IP
aws ecs update-service --cluster my-cluster --service my-service \
  --network-configuration "awsvpcConfiguration={subnets=[subnet-0abc],securityGroups=[sg-0abc],assignPublicIp=ENABLED}"

Verify

The runbook finds no connectivity issue on a rerun, and a new task pulls its image and starts.

Verify
aws ecs describe-tasks --cluster my-cluster --tasks <new-task-id> --query "tasks[0].containers[].[image, reason]"

Confirmed by docs.aws.amazon.com

Did this fix it?

How do I stop it coming back?

  • Tag every build with a unique version or commit ID and deploy that tag; reserve :latest for local use.
  • Before deleting images from a repository by hand, compare their digests with the imageDigest values that running tasks report.
  • Have the deploy pipeline run describe-images for the new tag before calling update-service, and stop if it fails.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Dispatch Pro, Raheeb, Loade Driver.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.