This is probably not a problem with nginx per se, but a problem with nodejs. Error 502 “bad gateway” means that nginx requested some information from the nodejs server, and the nodejs server answered, and then “hung up quickly”. “Hang up” refers more to the message part “Connection reset via peer-to-peer connection”.
Now this may indicate a lot of different problems, so I can’t give a definitive answer.
Perhaps an error occurred while processing the request, which would require tracking the error through js code.
Could this be a memory issue (what does your memory usage look like)?
Or it could be a timeout error in the node part, because the response has been returning for too long either due to an error in the code or due to lack of memory.
I know that I used intermittent timeout errors between nginx and php-fpm because nginx refused to wait for php. I adjusted memory usage and timeout settings to fix this (and I optimized the PHP code).
If you can provide more specific information about memory usage / loading or logs from a node or application or even a common template with 502 errors (is it localized in a geographic region, browser, OS?), Then the answer may be less speculative.
Shawn Patrick Rice
source share