Reputation: 85
I got (502 Bad Gateway nginx) from google cloud after I uploaded my node.js code to the app engine. I have no errors in my logs. I have done a lot of searching online and nothing helped, but I read some article saying that because the response time is long, the server returns (502 Bad Gateway).
This is my listening code:
const server = app.listen(8080, () => {
const host = server.address().address;
const port = server.address().port;
console.log("EDU-vents server started");
});
This is my app.yaml:
runtime: nodejs
env: flex
my package.json includes a start script
Thank you in advance.
Upvotes: 3
Views: 2898
Reputation: 140
Typically, when you encounter 5.x.x (502, 503, etc) it is recommended to wait a minute and try the request again. You may find more information about these errors specific to App Engine flexible environment.
However, most of the time the error code 502 with "BAD_GATEWAY" indicates that GAE terminated the application because it ran out of memory. By default, GAE Flex only has 1GB of memory and only 600MB is available for the application container. The following documentation describes steps on how to troubleshoot this type of error (You will have to most likely investigate your Stackdriver logs.
I recommend you to specify a higher CPU and Memory of your instance. If specifying a higher CPU and Memory doesn't work. I recommend you to check the Nginx error logs by following. Before SSHing to the VM instance, you need to enable debug mode for a VM instance
If this is not the case, do you have any support package/free trial? I'd recommend you to open a support ticket directly in their support center, if not you can contact Google through Google Issue Tracker as 5XX errors can be caused by different reasons.
Upvotes: 5