Troubleshooting
Symptom-to-Cause Reference
Section titled “Symptom-to-Cause Reference”Use this table to identify the likely cause of your deployment issue:
| Symptom | Likely Cause | Where to Look |
|---|---|---|
| Service spinning / rollback loops | New tasks fail ALB health checks repeatedly, triggering
RollbackAlarm | EC2 → Target Groups → Targets tab (health reason) |
503 errors from
Application URL | No healthy targets registered in the target group | EC2 → Target Groups → Targets tab |
| Private DNS resolution failure | VPC | VPC settings: |
| Health status “Unknown” on Tasks tab | Normal and expected — Express Mode does not define container-level healthCheck | No action needed (see explanation below) |
| Target group unhealthy | Security Group | EC2 → Target Groups → health reason column |
| Deployment rollback | ALB health checks fail within the deregistration delay, RollbackAlarm fires | ECS → Service → Events/Timeline, CloudWatch Alarms |
Deployment Rollback Flow
Section titled “Deployment Rollback Flow”When a deployment fails, Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs. follows a predictable rollback cycle:
- New tasks start with the updated task definition
- The health checks the new targets on the configured
health_check_path - Health checks fail (target returns non-200 or connection refused)
- The RollbackAlarm
A CloudWatch metric alarm created by Express Mode that triggers automatic deployment rollback when new tasks fail ALB health checks. fires after the evaluation period - Express Mode rolls back to the previous stable deployment
- The cycle repeats on the next deployment attempt until the root cause is fixed
Debug Order for Failed Deployments
Section titled “Debug Order for Failed Deployments”When your service fails to deploy, follow this order to find the root cause quickly:
Step 1: EC2 Target Groups health reason
Section titled “Step 1: EC2 Target Groups health reason”Navigate to EC2 → Target Groups → your target group → Targets tab. The health reason column tells you exactly why targets are unhealthy:
- Request timeout — container is not responding on the expected port
- Health checks failed — container responded with non-200 status
- Target not in service — task was deregistered or stopped
Step 2: CloudWatch Logs
Section titled “Step 2: CloudWatch Logs”Check the ECS task log group for container startup errors. Look for:
- Application crash stack traces
- Missing environment variables
- Port binding failures
- Permission denied errors
Step 3: ECS stopped task reason and exit code
Section titled “Step 3: ECS stopped task reason and exit code”In the ECS console, go to Cluster → Service → Tasks (stopped) and check:
- Stopped reason — why ECS stopped the task
- Exit code — the container’s exit code (non-zero indicates a crash)
- Exit code
1— application error - Exit code
137— killed by OOM (out of memory) - Exit code
139— segmentation fault
- Exit code
Step 4: curl the health endpoint
Section titled “Step 4: curl the health endpoint”From a resource within the same VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed. , curl the health check path directly:
curl -v http://<task-private-ip>:<container-port>/healthThis confirms whether the container is actually serving traffic on the expected port and path.
Common Root Causes
Section titled “Common Root Causes”These are the most frequent reasons for Express Mode health check failures:
Missing security group ingress
Section titled “Missing security group ingress”The task Security Group
A virtual firewall for EC2 instances and other resources that controls inbound and outbound traffic. must allow inbound traffic on the container port from the VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed. CIDR block. The lives within the same VPC and routes health check probes to task IPs.
ingress { from_port = var.container_port to_port = var.container_port protocol = "tcp" cidr_blocks = [aws_vpc.this.cidr_block]}Container exits on startup
Section titled “Container exits on startup”The container crashes before it can respond to health checks. Common causes:
- Missing required environment variables
- Database or dependency connection failures
- Incorrect entrypoint command
- Insufficient memory allocation
Wrong health_check_path
Section titled “Wrong health_check_path”The health_check_path in the Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs. configuration must match an endpoint that returns HTTP 200. If your application uses /healthz but the config says /health, checks will fail with 404.
Port mismatch
Section titled “Port mismatch”The container_port in the task definition must match the port your application actually listens on. If the app binds to port 8080 but container_port is set to 3000, the ALB cannot reach it.
Health Status “Unknown” Is Expected
Section titled “Health Status “Unknown” Is Expected”When viewing the ECS Tasks tab, you may see Health status: Unknown for your Express Mode tasks. This is normal and expected behavior.
Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs. does not define a
container-level healthCheck in the task definition. Instead, it relies
entirely on ALB target group health checks to determine whether tasks are
healthy. The “Unknown” status simply means ECS has no container-level health
information — it does not indicate a problem.
To confirm your service is healthy:
- Navigate to EC2 → Target Groups → Targets
- Verify targets show status healthy
- The Application URL
The unique Express-provisioned HTTPS URL on *.ecs.<region>.on.aws used for all normal application traffic. is accessible and returns expected responses