502 Bad Gateway errors

I’m getting 502 Bad Gateway errors when trying to reach my (docker environment) web service.

Based Web service returning HTTP/1.1 502 Bad Gateway - #2 by shantanu, it sounds like Render may be trying to send me HEAD requests to figure out what port the server is running on. I don’t want to bother responding to HEAD requests, so I just set the environment variable PORT to the appropriate port number of my server. That affected my internal host:port value but I’m still seeing 502’s externally. I have not tested reaching the server internally.

I can see from the server logs that no incoming requests are making it through. Oddly enough I’m not seeing any HEAD requests in the logs either. In the Events tab I can see “Deploy failed: Timed out” events, but what exactly timed out? There’s no description.

The Shell tab is also not working, and is behaving as described in [bug report] Never ending "Reconnecting..." cycle in the Shell tab.

The service in question is srv-c0abfrlua9vt7i8f5v2g.

Any pointers are greatly appreciated!

Hi Samuela, I checked the service, and looks like the reason was that your service never built successfully. When the deploy fails (check for failed deploys in the events tab of your service page), you will not be able to access your service through the onrender address. So I recommend looking at your build event and resolving the issue causing the build to fail. The shell tab flickering is happening because of the same reason, since the service never successfully ran, you won’t be able to access the shell.

I’m not sure how the build could be failing… When I look in the logs I clearly see

Jan 29 07:03:23 PM  Listening on http://127.0.0.1:3001

which is printed by my server once it’s up and running.

Is there some other sense in which you mean the build failed?

Thanks for sending this over, it makes things clear. My bad, looks like it was not the build but the fact that your application is listening on 127.0.0.1 instead of 0.0.0.0. If you can change this in your code, then the issue should be resolved.

1 Like

Ahhh, gotcha! I’ll give that a shot. Thanks!

2 Likes

Hi, I have the same challenge. Mine happens intermittently. Like 4 out of every 10 requests in a row will return 502. I’ve tried the ‘0.0.0.0’ and port recommendations. Still doesn’t work

I have the same issue. Is there any way to fix it?

Hi,

Since 502 errors are a general symptom that can have many causes, we would recommend reaching out directly regarding this. As this is about a specific service we’d request that you login to our dashboard and contact us via the ‘Help’ link at the top of our dashboard and make sure you pick the service that this question relates to from your account.

As this is a public forum it’s probably best not to share that directly here,

Regards,