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.