Checking stopped tasks for errors - Amazon ECS

Checking stopped tasks for errors

If you have trouble starting a task, your task might be stopping because of an error. For example, you run the task and the task displays a PENDING status and then disappears. You can view stopped task errors like this in the Amazon ECS console by viewing the stopped task and inspecting it for error messages.

Important

Amazon ECS also sends task state change events to EventBridge which you can view if your stopped task has expired from view in the Amazon ECS console. For more information, see Task state change events.

To check stopped tasks for errors (AWS Management Console)

  1. Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.

  2. On the Clusters page, select the cluster in which your stopped task resides.

  3. On the Cluster : clustername page, choose Tasks.

  4. 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.

  5. In the Details section, inspect the Stopped reason field to see the reason that the task was stopped.

    
                        Stopped task reason
  6. If you have a container that has stopped, expand the container and inspect the Status reason row to see what caused the task state to change.

    
                        Stopped container error

    In the previous example, the container image name cannot be found. This can happen if you misspell the image name.

    If this inspection does not provide enough information, see Stopped tasks error codes for more information.

To check stopped tasks for errors (AWS CLI)

  1. List the stopped tasks in a cluster. The output will contain the Amazon Resource Name (ARN) of the task, which you need to describe the task.

    aws ecs list-tasks \ --cluster cluster_name \ --desired-status STOPPED \ --region us-west-2
  2. Describe the stopped task to retrieve the stoppedReason in the response.

    aws ecs describe-tasks \ --cluster cluster_name \ --tasks arn:aws:ecs:us-west-2:account_id:task/cluster_name/task_ID \ --region us-west-2