Skip to content

ECS task stuck in the PROVISIONING state

0

My ECS task is stuck in the PROVISIONING state. How do I start looking into this?

asked 2 years ago6.1K views

2 Answers
9

1. Check ECS Service Events

Navigate to the ECS cluster in the AWS Management Console.

Select the service that is launching the task.

Go to the Events tab. This will show recent events and errors related to your ECS service, which can give you clues about why the task is stuck.

2. Verify Task Definition

Ensure that your task definition is correctly configured, with valid settings for containers, ports, environment variables, and resource requirements . Make sure that the Docker images specified in the task definition are available and can be pulled successfully.

3. Check Cluster Capacity

Verify that your ECS cluster has enough resources (CPU, memory) available to run the task.

If you are using EC2 instances, ensure that there are enough instances running with the required capacity. You can check the available resources on your instances in the ECS console under the Cluster -> Instances tab.

If you are using Fargate, ensure that your account has not hit any service limits (e.g., the maximum number of running tasks).

4. ECS Container Instances

If you are using EC2 launch type, ensure that your container instances are healthy and can communicate with the ECS service.

Check that the ECS agent is running on your container instances and is up-to-date.

Verify that the instances have the necessary IAM role and policies attached.

5. IAM Role Permissions Ensure that the task execution role specified in your task definition has the necessary permissions to pull images from Amazon ECR or other repositories and to start the task. The role should have policies like AmazonECSTaskExecutionRolePolicy.

6. Network Configuration Check the networking settings in your task definition, such as the VPC, subnets, and security groups.

Ensure that the subnets have available IP addresses.

Verify that the security groups allow the necessary traffic for your containers to operate.

7. Service Limits and Quotas

Check if you have hit any AWS service limits. For example, Fargate has limits on the number of tasks you can run per region.

You can view and request limit increases in the AWS Service Quotas console.

  1. Logs and Metrics

Check the CloudWatch logs for the ECS agent running on your container instances for any errors or warnings.

Use CloudWatch metrics to monitor the health and performance of your ECS cluster and tasks.

Steps to Resolve Review Events: Check the ECS service events for any error messages or indications of what might be going wrong.

Adjust Resources: If the cluster does not have sufficient resources, consider adding more EC2 instances or increasing the task memory/CPU limits.

Update Task Definition: Make sure that the task definition is correct and that the containers can start as expected.

IAM Roles and Permissions: Verify that all necessary IAM roles and policies are in place and correct.

Network Configuration: Ensure that the VPC, subnets, and security groups are properly configured.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

5
Accepted Answer

There are several reasons this can happen. Take a look at this article: https://repost.aws/knowledge-center/ecs-tasks-stuck-pending-state.

The following scenarios commonly cause Amazon ECS tasks to get stuck in the PENDING state:

  • The Docker daemon is unresponsive.
  • The Docker image is large.
  • The Amazon ECS container agent lost connectivity with the Amazon ECS service in the middle of a task launch.
  • The Amazon ECS container agent takes a long time to stop an existing task.
  • Your Amazon Virtual Private Cloud (Amazon VPC) routing isn't configured correctly.
  • An essential container depends on non-essential containers that fail to be HEALTHY.
AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.