View Amazon ECS stopped task errors - Amazon Elastic Container Service

View Amazon ECS stopped task errors

If you have trouble starting a task, your task might be stopping because of application or configuration errors. For example, you run the task and the task displays a PENDING status and then disappears.

When a task stops, the following fields are available:

  • stopCode - This string indicates the stopped task category. The following are valid values:

    • TaskFailedToStart - The task failed to transition to a RUNNING state.

    • EssentialContainerExited - A container process exited.

    • UserInitiated - A user stopped the task.

    • ServiceSchedulerInitiated - The service scheduler stopped the task.

    • SpotInterruption - An EC2 Spot Instance terminated or stopped.

    • TerminationNotice - The service scheduler received a Fargate termination notice.

  • stoppedReason - This provides addition information that you can use to resolve the issue. For example, "ResourceInitializationError: failed to initialize logging driver".

You can view stopped task errors by using any of the following methods:

  • Amazon ECS console


  • Amazon ECS API

  • AWS SDKs

  • Amazon CloudWatch Logs

    If your task definition uses the awslogs log driver, the application logs that are written to Amazon CloudWatch Logs for as long as the stopped tasks appears. The stopped tasks are also displayed on the Logs tab in the Amazon ECS console.

  • Amazon ECS also sends task state change events to Amazon EventBridge. You can't view events in EventBridge. Instead, you create rules to send the events to other persistent storage such as Amazon CloudWatch Logs. You can use the storage to view your stopped task details after it has expired from view in the Amazon ECS console. For more information, see Amazon ECS task state change events.

    For a sample EventBridge configuration to archive Amazon ECS events to Amazon CloudWatch Logs, see ECS Stopped Tasks in CloudWatch Logs on the GitHub website.

If your task was created by an Amazon ECS service, the actions that Amazon ECS takes to maintain the service are published in the service events. You can view the events in the AWS Management Console, AWS CLI, AWS SDKs, the Amazon ECS API, or tools that use the SDKs and API. These events include Amazon ECS stopping and replaces a task because the containers in the task have stopped running, or have failed too many health checks from Elastic Load Balancing.

If your task ran on a container instance on Amazon EC2 or external computers, you can also look at the logs of the container runtime and the Amazon ECS Agent. These logs are on the host Amazon EC2 instance or external computer. For more information, see Amazon ECS log file locations.

View stopped task errors

AWS Management Console

The following steps can be used to check stopped tasks for errors using the new AWS Management Console.

  1. Open the console at

  2. In the navigation pane, choose Clusters.

  3. On the Clusters page, choose the cluster.

  4. On the Cluster : name page, choose the Tasks tab.

  5. Configure the filter to display stopped tasks. For Filter desired status, choose Stopped or Any desired status.

    The Stopped option displays your stopped tasks and Any desired status displays all of your tasks.

  6. Choose the stopped task to inspect.

  7. In the row for your stopped task, in the Last Status column, choose Stopped.

    A pop-up window displays the stopped reason.

  1. List the stopped tasks in a cluster. The output contains 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

Error code resources

The following pages provide information about error codes: