views:

2818

answers:

4

We are running Drupal 5.x on Nginx with php-fastcgi. Things were working fine for a while. All of a sudden, we (users) are running into 502 Bad Gateway error. Restarting PHP-cgi, nginx.. rebooting machine etc did not help.

Did anyone else run into this type of issue? What are the possible suspects?

A: 

Usually when I have come across this it has been a fatal error in PHP somewhere. Have a look at your PHP-cgi log to see if it is in there. There should be something in the nginx log like this: 104: Connection reset by peer. Depending on your setup this might help but if you're using php-fpm it won't.

rojoca
+1  A: 

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.

Also, can you load stand alone PHP files that don't involve Drupal? Put putting <?php phpinfo(); ?> into a file called info.php and try hitting that and see what happens.

Good luck!

Douglas Muth
A: 

If the problem just started.. Read above.. if the server is new just setup, try this command to see if it's even listening on it's port

netstat -lpn | grep ":9000"

If course you could have setup fast-cgi to work on a different port, so just replace the port 9000 in that statement with what ever port you're looking for.. If nothing continues to show up, likely nothing is listening on that port and you need to fix that problem first.

Joshua
A: 

If you have firePHP disable it. Big headers causes problems while nginx comunication with php

nerkn