I'm currently testing Symfony2 with Nginx and PHP-FPM. I also use Xdebug.

Symfony2 comes with a Demo bundle, I wanted to test the new handling of fatal errors which comes with Symfony 2.2.0 by creating a syntax error in the Acme/Demo bundle. Why I do that, the server response is 502 bad gateway.

But if I make a syntax error in the file app_dev.php (so before the framework is fired), then Xdebug tells me about the fatal error.

And surprisingly, if I fix that typo, then re-create the syntax error in the Acme/Demo bundle, then Symfony error handler appears as expected. And finally if a fix all typos (page works) then again re-create that same typo (again in Acme/Bundle), I get a bad gateway.

Do you have any clue on this?

  • Any update? I have the same issue – Kevin Robatel Mar 20 '15 at 9:58
  • Here also for updates – Zaki Aziz Dec 31 '16 at 23:00
  • What line appears in your nginx error.log when you get the bad gateway error? This is 90% a wrong pointing to a PHP-FPM socket. Also, can you show us your nginx configuration and the PHP-FPM pool config you use? – Bert Nov 20 '17 at 12:24

This happened to me yesterday.It was an error handing off from nginx to php5-fpm turned out that the php-fpm service was configured to listen on the wrong socket.

in /etc/php5/php-fpm.conf I changed to:

listen = /var/run/php5-fpm.sock

and in all of /etc/nginx/ make sure fastcgi_pass unix:/var/run/php5-fpm.sock


| improve this answer | |

You could track the exact issue by checking the nginx logs.


502 is because there is some issue in connecting to the php-fpm process. Log can give you more details. If you want to isolate the log, mention seperate error_log under the location of your php application, like

    location <name> {

    error_log /var/log/nginx/site_location.error.log;
  #  error_log /var/log/nginx/site_location.error.log debug;


(if nginx is trying to connect to different port/ phpfpm/socket you could get answer from this)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.