How To Fix '502 Bad Gateway' Error In Nginx | Nginx always 502
The502BadGatewayerrorisanHTTPstatuscodethatmeansthatoneserverreceivedaninvalidresponsefromanotherserver.Inmoretechnicalwords,A502BadGatewaymeansthattheproxy(gateway)serverwasn’tabletogetavalidoranyresponsefromtheupstreamserver.Ifyouareseeinga502badgatewayerroronawebsite,itmeansthattheoriginserversentoutaninvalidresponsetoanotherserverthatactedasagatewayorproxy.Itcanbeatrickyinvestigationtolocatewhatandwhereistheprocesswhichcausedtheissue.However,therearesomegeneraltroubleshootingstepsthatyou...
The 502 Bad Gateway error is an HTTP status code that means that one server received an invalid response from another server. In more technical words, A 502 Bad Gateway means that the proxy (gateway) server wasn’t able to get a valid or any response from the upstream server.
If you are seeing a 502 bad gateway error on a website, it means that the origin server sent out an invalid response to another server that acted as a gateway or proxy. It can be a tricky investigation to locate what and where is the process which caused the issue. However, there are some general troubleshooting steps that you can follow to get it solved.
For example, if you use Nginx as the webserver and you encounter this issue, it could be that Nginx is unable to communicate with the upstream server, this upstream server could be PHP-FPM or other application that you want to access through Nginx, like Odoo, NodeJS, etc.
How to Fix 502 Gateway Error in NginxFirst, you need to in...