I'm literally struggling with Google App Engine to deploy my Node JS API as I always have a 502 error. I have seen many answers on this topic but none did it for me.

I've found in the log the following error:

"[error] 32#32: *4028 connect() failed (111: Connection refused) while connecting to upstream, client:, server: , request: "GET /_ah/health HTTP/1.1", upstream: ""

My idea is to change the upstream IP address, currently, how can I do so in Google App Engine ? Thanks

  • 1
    Can you try disabling health checks to see if for some reason your instances are simply too busy to respond to nginx's '_ah/health' and are falsely being labeled as unhealthy and are being closed.
    – Jordan
    Sep 14 '17 at 20:09
  • Hey @Jordan, I've disabled health_checks in app.yaml and it's working. I now have a 502 but I that might be another issue. Thank you for your help. If you want, put your comment into an answer and I'll accept it
    – t3__rry
    Sep 15 '17 at 8:14
  • Could you ask another question on ServerFault with the new 502 issue? Or in case you already asked, could you send us the link? Thanks
    – VictorGGl
    Jan 23 '18 at 14:16

'502' usually means that the nginx proxy that is responsible for handling requests for an App Engine Flexible instance has not been able to get in contact with your application and deems it to be unhealthy. This is done via health checks that nginx performs.

To test that this is indeed the case you can simply disable health checks in your yaml configuration file and the 502s should go away. Note that there are other higher level health checks in place that may still run and produce other 502s if your application is too busy to respond.

To ensure that health checks are handled by your application, your application must be able to respond to concurrent requests using asynchronous programming. There are many public guides available covering Async Node.js programming and it is highly recommended to investigate these paradigms when coding an application for the cloud.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.