A 502 Bad Gateway response indicates that an edge proxy or load balancer received an invalid or null response from the upstream service.
1.Inspect the Google Cloud Load Balancer Logs:
Navigate to Cloud Logging in the Google Cloud Console and filter for HTTP(S) Load Balancing logs (resource.type="http_external_lb_rule"). Look for the statusDetails field to pinpoint the exact failure reason (e.g., backend_connection_closed_before_data_sent_to_client, backend_timeout, or failed_to_pick_backend).
Verification: You identify a concrete statusDetails code and determine whether the LB failed to reach the backend or if the backend reset the connection.
2.Check Load Balancer Backend Health Checks:
Go to Network services > Load balancing, select the load balancer, and inspect the backend service. Check whether the backend instances or Network Endpoint Groups (NEGs) are passing health checks.
Verification: All backend targets display a green “Healthy” status.
3.Verify Target Environment & API Deployment:
If routing to an Apigee runtime or backend proxy, confirm that the API proxy (e.g., /hello-world) is fully deployed and the target environment is attached to the runtime instance and environment group.
Verification: The proxy overview shows a green deployment status for the target revision in the specified environment.
4.Check Firewall Rules & Network Peering:
Ensure VPC firewall rules allow incoming traffic from Google Cloud health check IP ranges (130.211.0.0/22, 35.191.0.0/16) and proxy-only subnets to reach your backend/MIG/NEG on the expected ports.
Verification: Test connectivity using VPC Network Intelligence Center Connectivity Tests or run a test request from a VM inside the same VPC.
5.Inspect Apigee Debug Session & Target Server:
If traffic reaches the Apigee runtime, start a Debug Session on the proxy. Check whether the failure occurs in Apigee itself (e.g., Target Endpoint connection failure or SSL handshake error with the target service) or if the upstream target (e.g., mocktarget.apigee.net) is timing out.
Verification: The trace shows whether the request reaches the target endpoint or faults out at a specific policy/step.