{ claus.conrad }

"Bad gateway" with nginx, PHP-FPM using FreeBSD socket

📅 Aug 30, 2014
⌛ 1 minute

After updating a FreeBSD jail I got the dreaded "502 Bad gateway" error from nginx, here's how I fixed it:

Apparently there is a bug in the PHP version shipped with FreeBSD; ServerFault user MafiaInc kindly provided the solution:

  1. Edit the file /usr/local/etc/php-fpm.conf

  2. Note the values of the user/group lines, e.g.:

    user = www  
    group = www
    
  3. Add these lines with the same values as the user/group lines:

    listen.owner = www  
    listen.group = www
    
  4. Restart PHP-FPM using this command:

    service php-fpm restart