Home > Enterprise >  ECS Health check failures AWS - copilot
ECS Health check failures AWS - copilot

Time:12-17

Whenever I try to redeploy my load balanced service in aws (via copilot) I keep getting health check failures (502 bad gateway) here's the error message:

(service my-app-my-env-my-service-Service-n6SienH8zSJt) (port 3000) is unhealthy in
(target-group arn:aws:elasticloadbalancing:us-east-1:[my target grouo]) due to (reason Health checks failed).     

I have a cluster (ECS) with two services (one backend service working totally fine, and then one load balanced service that's causing the issues) that each run one task (Fargate). The load balanced service is a meteor/node app which is listening on port 3000.

The Elastic Load Balancer (application) is listening on port 80 and it should be forwarding traffic to a target group for the service mentioned above which should be listening on port 3000.

This target group for the load balanced service has:

  1. Target type: IP
  2. IP address type: IPv4
  3. Protocol: Port -- HTTP:3000
  4. Protocol Version: HTTP1

The targets for this group have their own IP addresses with port 3000.

target type: ip address since I use fargate and not EC2 for my tasks. So when a task is turning on, I correctly see the private IP of the task registering into the target group.

A few notes:

  1. The server is launching correctly. I'm receiving logs that indicate a healthy server and no errors are showing up
  2. I have a /_health route which I set up and is working locally (getting my 200 status with a curl request to localhost:3000/_health). I'm pretty convinced that NO routes are working because i changed my app to render a static page regardless of the route and still having issues connecting. This makes me think the issues lies between the load balancer and the service

Been stuck on this for a week so if anyone knows what I'm missing that would be particularly helpful! I'm happy to share more information about my cluster if that will help! Thanks in advance :)

CodePudding user response:

What is the mapping of the health check route in your copilot manifest?

By default copilot configures health checks to target '/'.

CodePudding user response:

I feel pretty silly about this but pretty sure I found the solution. While I configured the port: 3000 correctly on the image in the manifest.yml, I needed an additional environment variable called PORT: 3000 in the variables for the manifest. This seemed to do the trick... like I said silly mistake!

  • Related