moin8
moin8

Reputation: 31

GCP external http load balancer 502 server error:"failed_to_connect_to_backend"

I have configured a http external load balancer on GCP and all my vm instances are healthy in backend. But when i am trying to access my server(installed on VM) from frontend static IP that is reserved at load balancer it is giving me 502 status error.

As a result of which i am unable to launch my application server using load balancer. Help me fix this issue.

Thanking you in advance.

Upvotes: 0

Views: 2069

Answers (2)

Ras
Ras

Reputation: 197

maybe you should check if the time taken for the API to return the response is exceeded the timeout that will trigger the 502. The default value is 30 seconds.

Ref: https://cloud.google.com/load-balancing/docs/backend-service#timeout-setting

Upvotes: 0

Neelam
Neelam

Reputation: 567

To troubleshoot 502 response from the Load Balancer due to "failed_to_connect_to_backend." I would check the followings:

  1. Usually, "failed_to_connect_to_backend" error message indicates that the load balancer is failing to connect to backends, investigating URL map rules is also a good point to start. I would also suggest reviewing your Load Balancer's URL map to make sure that Host rules, Path matcher, and Path rules are correctly defined and comply with descriptions in this article.
  2. Also check if the backend instances are exhausting their resources, If a backend server is overwhelmed, it will refuse incoming requests, potentially causing the load balancer to give up on it and return the specific 502 error you're experiencing. Also, check the output on how many established connections are present at any one time using 'netstat' and watch command.
  3. I would also recommend testing again with the HTTP(S) request directly to the instance, request the same URL that reporting 502. You might do this test in another VM instance in your VPC network.

Upvotes: 0

Related Questions