What it means when an ECS deployment never reaches a steady state, how to read the service events and stopped tasks to find the cause, and the five failures behind most cases: health checks, startup crashes, image pulls, secrets and capacity.

An ECS deployment reaches a steady state when the service has one deployment and the number of running tasks equals the desired count. When it does not, Terraform, CloudFormation or aws ecs wait services-stable waits, times out and reports that the service failed to reach a steady state, which says nothing about why.
The reason is almost always visible in two places, the service events and the last few stopped tasks, and it falls into a short list of causes.
The aws ecs wait services-stable command, per the AWS CLI reference, checks that every service has exactly one deployment and that the running count equals the desired count. It polls every 15 seconds and exits with code 255 after 40 failed checks, so a rollout that takes longer than 10 minutes fails the wait even if it would have succeeded a minute later.
Start with the service events, which are the first place AWS says to look for diagnostic information in the service event messages guide. Then read the stopped tasks, which is where the actual failure is recorded.
# What the scheduler tried, newest first
aws ecs describe-services --cluster prod --services api \
--query 'services[0].events[:10].[createdAt,message]' --output table
# Why recent tasks stopped
TASKS=$(aws ecs list-tasks --cluster prod --service-name api --desired-status STOPPED --query 'taskArns[:5]' --output text)
aws ecs describe-tasks --cluster prod --tasks $TASKS \
--query 'tasks[].[stoppedReason,containers[0].exitCode,containers[0].reason]' --output table
Stopped tasks stay visible for only a short time after they stop, so run the second command as soon as the wait fails. The stoppedReason text usually names the cause outright, for example a failed ELB health check, an essential container that exited, or a ResourceInitializationError.
Health checks fail. The load balancer marks the task unhealthy, ECS stops it and starts another, and the loop never ends. The usual reasons are a health check path that returns a redirect or a 404, a container port that differs from the target group port, a security group that blocks the load balancer, and an app that needs longer to start than the check allows. Setting healthCheckGracePeriodSeconds on the service, documented in the CreateService reference, gives a slow-starting app time before failed checks count.
The container exits on startup. An essential container that exits stops the whole task, and the exit code and the container's log group say why: a missing environment variable, a database that cannot be reached, a migration that failed or an out-of-memory kill with exit code 137. The log group only has content if the task definition's log configuration points at one that exists.
The image cannot be pulled. A wrong tag, a repository in another region or account, or a task in a private subnet with no route to ECR all show up as a CannotPullContainerError in the stopped reason, and fixing the route (a NAT gateway or VPC endpoints for ECR and S3) is the whole fix.
A secret cannot be read. A task whose definition references a Secrets Manager value that does not exist, or that the execution role cannot read, stops with a ResourceInitializationError before the container starts. Per the ECS secrets documentation, the execution role needs secretsmanager:GetSecretValue on the secret.
There is nowhere to place the task. Subnets with few free IP addresses, a Fargate task size that cannot be placed, or a service quota produce events that start with "unable to place a task", and the message names the missing resource.
Roll back to the last working task definition revision while you investigate, since a service that keeps trying a broken revision hides the working one behind failing tasks.
Encore brings infrastructure from code, and the parts of the task definition that go wrong by hand are generated: the container port, the target group, the health checks and the execution role come from the platform. Per the AWS infrastructure docs, each service runs on Fargate in private compute subnets that accept traffic only from the load balancer, with rolling updates that bring new tasks up before the old ones are removed.

Run in your terminal to get started locally.
The secret and bucket references that break a task by hand are declared next to the code that uses them:
// ingest/ingest.ts
import { api, APIError } from "encore.dev/api";
import { secret } from "encore.dev/config";
import { Bucket } from "encore.dev/storage/objects";
// A declared secret must have a value before a deploy is accepted.
const partnerToken = secret("PartnerToken");
const inbox = new Bucket("partner-inbox", { versioned: false });
interface Delivery {
token: string;
name: string;
body: string;
}
export const receive = api(
{ expose: true, method: "POST", path: "/ingest" },
async (req: Delivery): Promise<{ stored: string }> => {
if (req.token !== partnerToken()) throw APIError.unauthenticated("bad token");
if (!/^[a-z0-9._-]{1,100}$/.test(req.name)) throw APIError.invalidArgument("bad name");
const key = `incoming/${req.name}`;
await inbox.upload(key, Buffer.from(req.body), { contentType: "text/plain" });
return { stored: key };
},
);
Per the secrets docs, a deploy to a cloud environment fails when a declared secret is not set, so the missing-secret failure shows up before any task starts, and the fix is encore secret set followed by a redeploy without a new commit. Locally, encore run starts the service and a local bucket with a warning for the missing secret, so the startup path runs on a laptop before it reaches a cluster. The deploy troubleshooting docs cover failed deploys on the Encore side.
A coding agent that adds a secret or bucket changes only the service code, so there is no task definition or execution role edit for it to get wrong.
Best fit: Teams on ECS whose deployments stall on task definition, health check or secret mistakes and want those parts generated from the service code.
Read the last ten service events, then the stopped reason of the newest stopped task. If neither names a cause, compare the task definition revision that works with the one that does not, since the difference is usually one environment variable, one secret ARN or one port.
It means the service still has more than one deployment, or fewer running tasks than the desired count, when the wait ends. Terraform, CloudFormation and aws ecs wait services-stable all report it, and the cause is almost always that new tasks keep stopping before they become healthy.
The aws ecs wait services-stable command polls every 15 seconds and gives up after 40 failed checks, which is 10 minutes, and exits with code 255. Terraform and CloudFormation have their own timeouts, and a deployment can still succeed after the waiter has given up.
Run aws ecs describe-services and read the events, then run aws ecs describe-tasks on a recently stopped task and read stoppedReason and the container's exit code. The events say what the scheduler tried, and the stopped reason says what happened to the task.
Most of the causes are mistakes in the task definition, health check or secret references that only show up after the deploy starts. With Encore the task definitions, ports and health checks are generated, and a deploy fails before any task starts if a declared secret has no value.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.