How can I get my task to run in my Amazon ECS cluster?
Last updated: 2019-12-09
I'm trying to place a task in my Amazon Elastic Container Service (Amazon ECS) cluster. However, my task placement is failing, and my task won't change to the RUNNING state in my cluster. How can I resolve this issue?
Short Description
To successfully place your task in your cluster, choose one of the following solutions:
- If you placed your task with the Amazon ECS service, complete the steps in the Check your service event messages section.
- If you ran your task using a service, run task, or scheduled task, then follow the steps in the Check the stopped task for errors section.
Resolution
Check your service event messages
- Open the Amazon ECS console.
- In the navigation menu, choose Clusters, and then select the cluster that contains your service.
- On the Services tab of your cluster's page, in the Service Name column, select the service that you want to inspect.
- On your service's page, choose Events.
- In the Message column, look for errors or other useful information.
Based on your findings from step 5, choose one of the following resources to resolve your error:
- service (service-name) was unable to place a task because no container instance met all of its requirements.
- service (service-name) was unable to place a task because no container instance met all of its requirements. The closest matching container-instance container-instance-id has insufficient CPU units available.
- service (service-name) was unable to place a task because no container instance met all of its requirements. The closest matching container-instance container-instance-id encountered error "AGENT".
- service (service-name) (instance instance-id) is unhealthy in (elb elb-name) due to (reason Instance has failed at least the UnhealthyThreshold number of health checks consecutively.)
- service (service-name) is unable to consistently start tasks successfully.
Note: Service events display only the last 100 events.
Check the stopped task for errors
Important: You can see a stopped task that was stopped only in the last 30 minutes.
- Open the Amazon ECS console.
- In the navigation menu, choose Clusters, and then select the cluster that contains your stopped task.
- On your cluster's page, choose the Tasks tab.
- In the Desired task status table header, choose Stopped, and then select the stopped task to inspect. The most recent stopped tasks are listed first.
- On the Details tab of your stopped task, inspect the Stopped reason field to find out why your task was stopped.
- If you have a container that's stopped, expand the container, and then inspect the Status reason row to see what caused the task state to change.
Based on your findings from step 6, choose one of the following resources to resolve your error:
- Task failed ELB health checks in (elb elb-name)
- Scaling activity initiated by (deployment deployment-id)
- Host EC2 (instance id) stopped/terminated
- Container instance deregistration forced by user
- Essential container in task exited
- Cannot Pull Container Image Error
- API failures Error Messages
Note: If you're using any task placement constraints or strategies, your cluster must use instances that meet the requirements of your constraints or strategies.
Did this article help you?
Anything we could improve?
Need more help?