> ## Documentation Index
> Fetch the complete documentation index at: https://docs.springwinter.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Debug failed builds and restarting ECS tasks

> Find the first build, startup, memory or workflow failure using scoped logs and ECS task evidence, then repair the cause without duplicating resources.

A failed SpringWinter deployment can stop during the build, image pull, task startup or health wait. Diagnose the earliest failed stage before retrying. An accepted API request or completed build is not proof that the replacement task is healthy.

## First separate the failure stages

| Symptom | Likely layer | Check first | Repair and prevention |
| - | - | - | - |
| Docker build exits | Build | First failing command, dependency lockfile, build context and Dockerfile stage | Reproduce the same build locally with non-secret configuration; pin dependencies and correct context |
| Repository unavailable | Source authorization | Connected GitHub installation, selected repository and branch | Repository owner grants intended access; do not install across unrelated private repositories |
| Image pull error | Registry or runtime | Public image tag/digest, registry availability, architecture | Use a compatible public image or supported GitHub build; arbitrary private-registry credentials are not supported |
| `exec format error` | Image architecture | Image architecture versus target runtime, entrypoint/shebang | Build a compatible image; do not assume an Apple Silicon image runs on x86 |
| Container exits immediately | Application startup | Exit code and stderr, command, missing runtime names | Correct the startup command/configuration; keep secrets out of diagnostics |
| `OutOfMemoryError` or repeated exit 137 | Memory or termination | Task stopped reason and memory metrics, application heap/concurrency | Bound heap and job concurrency or approve more memory; exit 137 alone is not conclusive proof of OOM |
| Locally works, deployed fails | Environment/network | Bind address, port, build-versus-runtime variables, external service access | Bind the HTTP process to all container interfaces, match the configured port, test actual runtime |
| Workflow timeout | Observation or slow dependency | Current workflow/resource and AWS task state | Reconcile existing resources first; do not create a duplicate or assume AWS rolled back |

## Diagnose with SpringWinter

Open the resource **History** and find the first failed workflow step. Read only the relevant build/application log interval. Then inspect resource **Home** and **Metrics**. Compare the intended source commit, image and settings with the currently running service. A settings save can require a redeploy; a runtime-variable save can roll tasks. See [environment scopes](https://docs.springwinter.dev/concepts/environment-variables.md).

An agent should use the [current API reference](https://docs.springwinter.dev/api-reference/agents.md) for workflow and resource inspection. Keep request bodies grounded in the live schema. After an uncertain response, inspect existing resources and workflow status before retrying the mutation.

## Diagnose directly in AWS

Use a customer-authorized AWS profile and the observed Region/cluster. These are read-only inspection examples, not permission to access an unrelated account:

```sh theme={null}
aws sts get-caller-identity --profile "$AWS_PROFILE"
aws ecs list-tasks --profile "$AWS_PROFILE" --region "$AWS_REGION" \
  --cluster "$ECS_CLUSTER" --desired-status STOPPED
aws ecs describe-tasks --profile "$AWS_PROFILE" --region "$AWS_REGION" \
  --cluster "$ECS_CLUSTER" --tasks "$ECS_TASK_ARN" \
  --query 'tasks[].{status:lastStatus,stopCode:stopCode,reason:stoppedReason,containers:containers[].{name:name,exitCode:exitCode,reason:reason}}'
```

Read service events and task logs as needed. Do not dump a task definition or environment values into chat. Stopped-task history is limited; capture a sanitized failure reason while it is available. AWS's [stopped-task guide](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/stopped-task-errors.html) explains the diagnostic fields and service events.

For image inspection, run `docker image inspect` on the exact locally built image with a format selecting only architecture and operating system. This does not prove the image works on AWS. A successful build must be followed by startup, health, connectivity and application checks.

## Repair one cause, then verify replacement

Fix the earliest root cause, run the appropriate local test/build, and review the cost/effect of a redeploy. Wait for the returned workflow. Confirm that new task IDs and the intended task definition are serving traffic, then test a representative application request. Do not test persistence while an old task is still answering requests.

For jobs, verify durable output and retry/acknowledgement behavior. Do not rerun a non-idempotent payment or message operation simply to test recovery. For migrations, use a new isolated database or disposable complete copy first. Never experiment against an existing database.

## Related diagnostics

* [HTTP health, domains and TLS](https://docs.springwinter.dev/troubleshooting/http-and-domains.md)
* [Private SQL and Valkey connectivity](https://docs.springwinter.dev/troubleshooting/data-connectivity.md)
* [IAM, CloudFormation and GitHub access](https://docs.springwinter.dev/troubleshooting/account-access.md)
* [Compatibility](https://docs.springwinter.dev/reference/compatibility.md) and [Docker configuration](https://docs.springwinter.dev/deploy/frameworks/docker.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.