ECS "Unable to Place a Task": Every Cause and Fix

Logeshwaran
—

ECS “unable to place a task” means the scheduler found nowhere to run your task; the end of the message tells you exactly why.

The short version: read the whole message in the service’s Events tab. On EC2, “no container instance met all of its requirements” means no instance had enough free CPU, memory, host ports or network interfaces, or none matched a placement rule; the “closest matching container-instance” part names what was missing. Add instances, lower the task’s CPU or memory, or switch fixed host ports to dynamic ones. On Fargate, the reason names a capacity shortage or an account limit instead: add subnets in more Availability Zones, or request a quota increase.

The surprise: a bigger instance often fixes nothing. If your task maps a fixed host port such as 80, only one copy can run on each instance, however large it is.

Jake’s booking app ran on two EC2 instances, one task on each, both listening on host port 80. Every deploy until Friday’s had been quick. Friday’s hung, and the Events tab filled with the same line every few minutes.

Jake: "It says it can’t place a task. Do we need bigger servers?"

Ethan: "No. The new copies want port 80 too, and both servers already have a task on 80. There’s nowhere for them to go."

Read the whole message first

The first half of the message is always the same. The second half is the diagnosis. Open the cluster, choose the service, and read the newest lines on the Events tab, or pull them from the CLI:

aws ecs describe-services --cluster shop --services booking \
  --query "services[0].events[:5].message" --output text

Match the ending to this table. The wording comes from the ECS service event messages reference; your service and instance IDs replace the placeholders.

Message ends withWhat it meansFirst fix
…has insufficient CPU units availableNo instance has enough free CPU for the taskLower task CPU or add capacity
…no container instance met all of its requirements (and nothing more)Several causes at once, or no instances at allCheck instances, then each cause below
…is already using a port required by your taskFixed host port already taken on that instanceDynamic host ports or awsvpc
…encountered error "AGENT"The ECS agent on that instance is disconnectedRestart the agent, read its log
…No Container Instances were found in your capacity providerThe capacity provider has no running instancesCheck the Auto Scaling group
Reason: Capacity is unavailable at this timeFargate (or EC2) capacity shortage in your AZsWait, or add subnets in other AZs
Reason: You’ve reached the limit on the number of tasks / vCPUsAccount quota reachedRequest a quota increase
Reason: The requested CPU / MEMORY configuration is above your limitTask size above your account limitSmaller task or a quota increase
Reason: Internal errorOften a subnet in an AZ Fargate doesn’t supportRemove that subnet

Behind every one of these, ECS also emits a SERVICE_TASK_PLACEMENT_FAILURE service event, which you can route to an alert through EventBridge, as the service action events page shows.

Not enough CPU or memory: do the arithmetic

On EC2, each container instance offers 1,024 CPU units per vCPU. A task asking for 1,000 units fits once on a 1-vCPU instance; a second copy needs another instance. Memory works the same way: a task reserving 1,000 MiB on instances that offer 1,024 MiB runs once per instance.

Check what is really free, not what the instance type advertises. ECS registers a little less memory than the instance has, because the operating system and the agent need some:

aws ecs list-container-instances --cluster shop --query containerInstanceArns --output text

aws ecs describe-container-instances --cluster shop --container-instances ARN1 ARN2 \
  --query "containerInstances[].{id:ec2InstanceId,free:remainingResources[?name=='CPU'||name=='MEMORY'].integerValue}"

Then compare with the task definition. Look at both the task-level cpu and memory and each container’s values; the larger reservation wins. Our task definition examples show where each one sits.

  • Over-reserved tasks: a 2 GB reservation for an app that uses 600 MB blocks placement for nothing. Use the memory metrics to size it.
  • Too few instances: raise the Auto Scaling group’s desired count, or let a capacity provider do it (below).
  • Instance too small for even one copy: if the task needs more than any instance offers, no amount of scaling out helps; use a larger instance type.

Jake: "Our tasks reserve 2 GB each, but the app uses about 600 MB. Does that matter?"

Ethan: "It’s the whole problem on a small cluster. ECS counts the reservation, not what the app uses."

“Already using a port required by your task”: fixed host ports

This is Jake’s Friday. In bridge or host network mode, a task that maps a fixed host port, such as "hostPort": 80, can run only once per instance, because only one process can listen on a host port at a time. Two instances means at most two copies, ever.

That bites hardest during deployments. A rolling deployment starts new tasks before it stops old ones (up to maximumPercent, 200% by default), and the new copies need port 80 on an instance that is already using it. Three fixes, best first:

  1. Dynamic host ports: set "hostPort": 0 (or leave it out) in bridge mode, and let an Application Load Balancer target group track the random port each task gets.
  2. awsvpc network mode: each task gets its own network interface and IP address, so ports never collide (it has its own limit, below).
  3. Make room during deploys: lower minimumHealthyPercent so ECS may stop an old task before starting the new one, at the cost of reduced capacity during the deploy.

There is also a ceiling: a container instance can reserve at most 100 host ports. Dynamic port mapping avoids that one too.

Jake: "So we switch to random ports and the load balancer finds them?"

Ethan: "Exactly. The target group registers whatever port each task gets. Deploys get their room back."

awsvpc tasks on EC2: network interface limits

With the awsvpc network mode, every task gets its own elastic network interface (ENI) attached to the instance. Each instance type can attach only a few, and the instance’s own primary interface uses one of them. Run out, and placement fails even with plenty of CPU and memory free.

  • Turn on ENI trunking: opt in to the awsvpcTrunking account setting. It raises the limit on supported instance types, but only for container instances launched after you opt in, so replace the old ones.
  • Match the subnets: a container instance must be registered in a subnet listed in the service’s awsvpcConfiguration. If the instances live in other subnets, nothing can be placed.
  • Watch subnet IP addresses: each task uses one; a full subnet fails differently, covered in our not enough free addresses in subnet fix.
aws ecs put-account-setting --name awsvpcTrunking --value enabled

No container instances, or the agent is disconnected

If the message has no “closest matching” part, check that the cluster has instances at all. The cluster’s Infrastructure tab lists registered container instances; an empty list means the EC2 instances never joined. The usual reasons:

  • The instance’s user data writes a different cluster name. On the ECS-optimized AMI, /etc/ecs/ecs.config must contain ECS_CLUSTER=your-cluster.
  • The instance profile lacks the ECS permissions the agent needs to register.
  • The instance can’t reach the ECS endpoints: no NAT gateway, VPC endpoints or public IP in its subnet.

If instances are listed but the message says encountered error "AGENT", the ECS agent on that instance is disconnected. Connect to the instance and restart it:

sudo systemctl restart ecs          # ECS-optimized Amazon Linux 2 / 2023
sudo tail -n 50 /var/log/ecs/ecs-agent.log

AWS also publishes a Systems Manager runbook, AWSSupport-TroubleshootECSContainerInstance, that checks the user data, instance profile and network path for you.

Placement constraints and missing attributes

Sometimes every instance has room, but none is allowed to run the task. Placement constraints do that by design:

ConstraintWhat it doesHow it blocks placement
distinctInstanceOne task per container instanceMore desired tasks than instances
memberOf + expressionOnly instances matching the expressionNo instance matches, e.g. a typo in an instance type or AZ

The other hidden requirement is attributes. Some task definition settings need the instance to advertise support for them. A logging driver such as awsfirelens or splunk must be listed in ECS_AVAILABLE_LOGGING_DRIVERS in the agent configuration, and some parameters need a minimum Docker API version. If no instance advertises the attribute, the task can’t be placed.

aws ecs describe-services --cluster shop --services booking --query "services[0].placementConstraints"
aws ecs list-attributes --cluster shop --target-type container-instance --attribute-name ecs.instance-type

Capacity providers: the launch type trap

Capacity providers add EC2 instances when tasks can’t be placed, but only if the service actually uses one. A service created with a launch type (EC2) ignores capacity providers entirely, so tasks wait while the Auto Scaling group sits still. Pass a capacity provider strategy, or rely on the cluster’s default strategy, and don’t pass a launch type.

“No Container Instances were found in your capacity provider” means the provider’s Auto Scaling group has no running instances, often because its maximum is 0 or its launch template is broken. Our capacity provider not scaling guide walks through both.

Jake: "The Auto Scaling group never added a server. Isn’t that its job?"

Ethan: "Only for services that ask it to. Ours was created with the old launch type, so it never asked."

Fargate: capacity and account limits

Fargate has no instances for you to fill, so the EC2 causes above don’t apply. Its placement failures end with a Reason:

  • Capacity is unavailable at this time: Fargate has no room in your service’s Availability Zones right now. Wait and retry, or give the service subnets in more Availability Zones so it has somewhere else to go.
  • Limit on the number of tasks or vCPUs you can run concurrently: your account reached a service quota. Request an increase in Service Quotas.
  • The requested CPU or MEMORY configuration is above your limit: the task size is larger than your account allows; shrink it or request a higher quota.
  • Internal error: a common cause is a subnet in an Availability Zone that Fargate doesn’t support. Remove it from the service.

“Unable to stop or start tasks during a deployment”

A close cousin of the placement error: ECS can place tasks, but the deployment settings forbid it from making progress. With minimumHealthyPercent at 100 and maximumPercent at 100, ECS may neither stop an old task first nor start an extra new one. Widen one of them:

aws ecs update-service --cluster shop --service booking \
  --deployment-configuration "minimumHealthyPercent=50,maximumPercent=200"

If a deployment is already stuck, our ECS deployment stuck guide covers forcing it through or rolling it back safely.

Jake’s checklist

  1. Read the end of the event message and match it to the table.
  2. EC2: compare remainingResources with the task’s CPU and memory reservations.
  3. Fixed host port? Switch to dynamic ports or awsvpc, or lower minimumHealthyPercent.
  4. No instances or an AGENT error? Check ECS_CLUSTER, the instance profile and the agent log.
  5. awsvpc on EC2? Check ENI limits, trunking and the service’s subnets.
  6. Constraints or attributes? Check distinctInstance, memberOf and logging drivers.
  7. Fargate? Add subnets in more AZs, or request a quota increase.

Jake: "So the fix was one number in the task definition."

For readers preparing for an AWS certification

We have been covering AWS certifications alongside our fixes, so here is a short extra for readers studying for one. If you only came for the fix, you already have it; feel free to skip this part.

Exams that test this topic: CloudOps Engineer – Associate (SOA-C03) • Developer – Associate (DVA-C03 from December 1, 2026) • Solutions Architect – Associate (SAA-C03) • DevOps Engineer – Professional (DOP-C02).

Here are the exam-style questions this topic tends to raise, with the reasoning you need to answer them:

1. An ECS service on EC2 runs two tasks on two container instances. Each task maps host port 80. Every deployment hangs with "unable to place a task". What is the most effective fix?

Use dynamic host port mapping (hostPort 0) with an Application Load Balancer target group, or the awsvpc network mode. With a fixed host port only one task fits per instance, so the new tasks of a rolling deployment have nowhere to run.

2. ECS reports that the closest matching container instance has insufficient CPU units available. Each instance has 1 vCPU and the task definition reserves 1,000 CPU units. How many copies fit per instance?

One. A container instance offers 1,024 CPU units per vCPU, so a second 1,000-unit task cannot fit. Lower the reservation or add instances.

3. A team opted in to the awsvpcTrunking account setting, but awsvpc tasks still fail to place because of ENI limits. What did they miss?

Trunking only applies to container instances launched after opting in, on supported instance types. The existing instances must be replaced.

4. A cluster has an Auto Scaling group capacity provider, but tasks stay unplaced and no instances are added. The service was created with launch type EC2. What should change?

Recreate or update the service to use a capacity provider strategy (or the cluster default strategy) instead of a launch type. Services that use a launch type do not trigger capacity provider scaling.

5. A Fargate service fails with "Capacity is unavailable at this time". What can the team do without changing the task size?

Retry later, or add subnets in additional Availability Zones to the service so Fargate can place tasks where capacity is available.

6. An ECS service has minimumHealthyPercent 100 and maximumPercent 100, and deployments never progress. Why?

ECS may neither stop an old task before starting a new one nor run extra tasks during the deployment. Lower minimumHealthyPercent or raise maximumPercent.

Exam codes and dates change often. Our AWS certification changes page keeps track of what is current.

Ethan: "Port zero instead of port 80. Friday’s deploy went out in four minutes."

Official references for this guide

Frequently asked questions

What does "unable to place a task" mean in ECS?

The ECS scheduler couldn't find anywhere to run a new copy of your task. On EC2, no container instance had enough free CPU, memory, ports or network interfaces, or none matched the task's placement rules. On Fargate, the reason names a capacity or account limit.

What does "no container instance met all of its requirements" mean?

Every EC2 instance in the cluster failed at least one requirement of the task: free CPU, free memory, a free host port, a free network interface, a required attribute or a placement constraint. The rest of the message names the closest match and what it lacked.

How do I fix "has insufficient CPU units available"?

Lower the task's CPU in the task definition, or add container instances or larger ones. A container instance has 1,024 CPU units per vCPU, so a task asking for 1,000 units fits only once on a 1-vCPU instance.

Why does ECS say a container instance "is already using a port required by your task"?

The task maps a fixed host port, such as 80, and a task on that instance already uses it. Only one task can use a host port on an instance. Use dynamic host ports (hostPort 0) behind a load balancer, or the awsvpc network mode.

Why can't ECS place a task during a deployment when the service was running fine?

A rolling deployment starts new tasks before stopping old ones, so it needs spare room for the extra copies. With fixed host ports or a full cluster there is none. Add capacity, use dynamic ports, or lower minimumHealthyPercent so old tasks can stop first.

What does "encountered error AGENT" mean?

The ECS container agent on that instance is disconnected, so the scheduler can't place tasks there. Check that the agent is running and read its log; on the ECS-optimized Amazon Linux 2 and 2023 AMIs, sudo systemctl restart ecs restarts it.

Why does ECS say no container instances were found in my cluster?

No EC2 instance has registered with that cluster. Usually the instance's user data names a different cluster (ECS_CLUSTER in /etc/ecs/ecs.config), the instance profile lacks ECS permissions, or the instance can't reach the ECS endpoints.

Does a bigger EC2 instance fix "unable to place a task"?

Only when CPU or memory is what ran out. If the cause is a fixed host port, a placement constraint or a missing attribute, a bigger instance changes nothing; you need more instances or a different task definition.

How many ENIs can an ECS container instance have for awsvpc tasks?

Each awsvpc task gets its own network interface, and each instance type has a limit. Opting in to the awsvpcTrunking account setting raises it for supported instance types, but only on container instances launched after you opt in.

What does "Capacity is unavailable at this time" mean on Fargate?

Fargate has no capacity for your task in the Availability Zones your service uses at that moment. Wait and retry, or give the service more subnets in other Availability Zones.

What does "You've reached the limit on the number of tasks you can run concurrently" mean?

Your account hit an ECS or Fargate service quota. Request a quota increase in Service Quotas for the resource the message names, or stop tasks you don't need.

What does "unable to place a task. Reason: Internal error" mean?

One common cause is a subnet in an Availability Zone that Fargate doesn't support. Check the service's subnets against the supported Availability Zones and remove the unsupported one.

Can placement constraints stop ECS from placing a task?

Yes. distinctInstance allows one task per instance, and a memberOf expression limits tasks to instances that match it. If no instance satisfies the rule, the task isn't placed even when there is free CPU and memory.

Why does ECS fail to place a task with a custom logging driver?

The task needs an instance attribute the agent hasn't registered. A logging driver must be listed in ECS_AVAILABLE_LOGGING_DRIVERS on the instance, and some task definition parameters need a minimum Docker API version.

How do I see free CPU and memory on ECS container instances?

Run aws ecs describe-container-instances and read remainingResources for CPU, MEMORY and PORTS. The console shows the same per instance under the cluster's Infrastructure tab.

Does "unable to place a task" mean my container is broken?

No. The task never started, so your image and code weren't involved yet. It is a capacity or configuration problem; a broken container shows up as stopped tasks instead.

Revision note. Written November 27, 2026, against the current Amazon ECS service event messages. “Measure twice, cut once”: read the whole message before you resize anything.

Related