502 errors are usually caused when PHP freaks out for some reason. The first thing you should do is check all of your logfiles. That includes system stuff in /var/log/ and the nginx logs.

If you haven't made any recent changes and the problem just started happening for no apparent reason, PHP may be running out of memory. I know when it happens as an Apache module it gives a blank screen--wouldn't be surprised if a 502 error happened under nginx and the FastCGI interface. That's easy to fix by putting ini_set('memory_limit', '256M') into your index.php and see if that fixes the problem.


Source(google)
CrocShare Reviewed by CrocShare on . Nginx Bad Gateway Errors Hello Peps ;) , i installed nginx as reserve proxy in Cpanel by some auto installer , all goes super fine , and now the sites are working faster then before. But the problem is really wired , i am getting Nginx 502 Bad Gateway errors while logging into my site , while editing any posts , while creating any posts , etc . Except then this the Front end interface is super fine and clean with no errors . http://screensnapr.com/e/TAraOQ.png Please suggest me the ways to solve them . Rating: 5