I am unable to make Post API call in ALB

Viewed 108

I have created an API that has two endpoints. I containerized that API and deployed that into the ECS Fargate container behind the Application Load Balancer. End Points.

  1. Get = Return the status of the API
  2. Post = Insert data into the RDS.

api/v1/healthcheck is working api/v1/insertRecord is not working => 502 bad Gateway The problem I am running into is that I am able to get the HealthCheck response but I am not able to make the Post API call I am getting 502 Bad Gateway error

Target Group

My target group is directed to the healthcheck endPoint so my ecs stays up. Can someone plz tell me where am I making mistake?

1 Answers

The 502 (Bad Gateway) status code indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request. if the service returns an invalid or malformed response, instead of returning that nonsensical information to the client.

Possible causes: taken from

  1. check protocol and port number during REST call
  2. The load balancer received a TCP RST from the target when attempting to establish a connection.
  3. The load balancer received an unexpected response from the target, such as "ICMP Destination unreachable (Host unreachable)", when attempting to establish a connection.
  4. The target response is malformed or contains HTTP headers that are not valid.
  5. The target closed the connection with a TCP RST or a TCP FIN while the load balancer had an outstanding request to the target.

you can enable cloudWatch log for further debugging.

Related