Question: I suddently get a 502 Bad gateway error and I don't understand why this error appear. This error appear moreover only for 1 single page!!...

The exact error in my Nginx log is :

```
 Upstream prematurely closed FastCGI stdout while reading response header from upstream [..] upstream: "fastcgi://unix:/var/run/php5-fpm.sock:"

```

I tried :

* service nginx restart : NOTHING CHANGE
* service php5-fpm restart : NOTHING CHANGE
* to reboot the server : NOTHING CHANGE
* even to restart the mysql service : NOTHING CHANGE

My /var/log/upstart/php5-fpm.log (only a lot of NOTICES) :

```
Terminating...
exiting, bye-bye!
fpm is running, pid 9887
ready to handle connections
systemd monitor interval set to 10000ms

```

that makes me crazy, any idea ?

Answer: 
Strangely enough, this is what worked for me after chasing down a mysterious 502 Bad Gateway error:

* Change `error_reporting` setting in `php-fpm` ini like this:

`error_reporting = ~E_ALL`
* Then restart `php-fpm` and `nginx`

This worked for me after trying the suggested nginx settings above to no avail. I don't have a verified explanation for this, but it would appear that excessive error reporting can overload the php-fpm process.
I did the following to server nginx config:

```
   client_body_timeout 1200;
   client_header_timeout 600;

```

and added zend\_extension to php fpm php.ini:

```
zend_extension = xdebug.so

```