2

I have a simple web service running on AWS Fargate. It works just fine locally but on Fargate it keeps on restarting every few minutes, i.e. stopping and creating new tasks. There is nothing in the logs.

Any idea what could be wrong / how to troubleshoot?

Jakub Holý
  • 393
  • 1
  • 4
  • 15

1 Answers1

5

The problem was that the service did not respond with HTTP code 200 at /, used by default by the load balancer Target Group's health check. (Because the service requires authentication, it responded with 401.) It was indicated by this Event on the ECS Task:

service TestService (port 8081) is unhealthy in target-group MainCluster-TestService due to (reason Health checks failed with these codes: [401]).

The solution for me was to check (starts-with? (get-in request [:headers "user-agent"] "") "ELB-HealthChecker/") and returning status 200 when it did.

Jakub Holý
  • 393
  • 1
  • 4
  • 15