502 Bad Gateway, PHP won't start

I am setting up a new project on my machine. I followed all the normal steps outlined in setting up trellis. After all the configuration is complete I run vagrant up. Everything runs through fine with no errors but when I hit the local site I get 502 Bad Gateway ngix.

I have setup a few other sites using trellis with no issues in the past until today. I googled and searched through the community for roots but the issues that other people are reporting don’t seem to matchup to my local install. Has any else had this issue?

Additional Notes:
I just setup another fresh project and I am getting the same issue. Did something change in trellis recently

1 Like

I’ve got the exact same problem. I’m getting these errors in my site-specific nginx log:

2016/05/09 20:32:17 [error] 884#884: *9 connect() to unix:/var/run/php-fpm-wordpress.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.50.1, server: example.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm-wordpress.sock:", host: "example.dev"

I changed my dev URL back to example.dev for my client’s privacy.

1 Like

Where do you find this log. I will check mine and see if it matches

It’s in /srv/www/example.dev/logs/error.log.

me too. co-worker has just hit a bump in the road today with the same kind of behavior. when you vagrant ssh and then sudo service php7.0-fpm start; sudo service php7.0-fpm status it shows you that php7.0-fpm is not running.

Not sure where that path is located on my computer. I am running a macbook pro if that helps

@mwalcott ot you can get to the file by doing a vagrant ssh from the folder Trellis is in on your MBP. You will then be inside the Vagrant box, where you can find the file in the mentioned path. You can get a printout by doing cat /srv/www/example.dev/logs/error.log. You should change example.dev to the site you are working on.

I’m getting that too.

When I do a service php7.0-fpm restart (because it should be running), it reports stop: Unknown instance: followed by php7.0-fpm start/running, process 2677 which suggests it now works, but it doesn’t.

2 Likes

Yeah I see the same exact error above on my machine

could php7 be the issue or is this standard for trellis

I’ve had PHP7 working fine on production servers for a while now, so that shouldn’t be it. First thing I thought was maybe some permissions or user related error, but everything seems fine regarding that. The socket is also present in /var/run and the nginx and php-fpm config files look fine on first glance.

I found some more diagnostic info in /var/log/syslog.

May 9 20:59:24 example kernel: [ 1767.812449] init: php7.0-fpm main process (2766) terminated with status 78 May 9 20:59:24 example kernel: [ 1767.812457] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1767.868332] init: php7.0-fpm main process (2770) terminated with status 78 May 9 20:59:24 example kernel: [ 1767.868341] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1767.916326] init: php7.0-fpm main process (2774) terminated with status 78 May 9 20:59:24 example kernel: [ 1767.916334] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1767.960297] init: php7.0-fpm main process (2778) terminated with status 78 May 9 20:59:24 example kernel: [ 1767.960307] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1768.004180] init: php7.0-fpm main process (2782) terminated with status 78 May 9 20:59:24 example kernel: [ 1768.004190] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1768.047454] init: php7.0-fpm main process (2786) terminated with status 78 May 9 20:59:24 example kernel: [ 1768.047482] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1768.092452] init: php7.0-fpm main process (2790) terminated with status 78 May 9 20:59:24 example kernel: [ 1768.092461] init: php7.0-fpm main process ended, respawning May 9 20:59:24 example kernel: [ 1768.136987] init: php7.0-fpm main process (2794) terminated with status 78 May 9 20:59:24 example kernel: [ 1768.136998] init: php7.0-fpm main process ended, respawning May 9 20:59:25 example kernel: [ 1768.181719] init: php7.0-fpm main process (2798) terminated with status 78 May 9 20:59:25 example kernel: [ 1768.181729] init: php7.0-fpm main process ended, respawning May 9 20:59:25 example kernel: [ 1768.225062] init: php7.0-fpm main process (2802) terminated with status 78 May 9 20:59:25 example kernel: [ 1768.225070] init: php7.0-fpm main process ended, respawning May 9 20:59:25 example kernel: [ 1768.270812] init: php7.0-fpm main process (2806) terminated with status 78 May 9 20:59:25 example kernel: [ 1768.270823] init: php7.0-fpm respawning too fast, stopped May 9 21:00:01 example CRON[3117]: (vagrant) CMD (curl -k -s ${WP_HOME}/wp/wp-cron.php > /dev/null 2>&1)

Seems to have something to do with a cron job?

I checked to make sure I didn’t have multiple vagrant boxes running and I don’t. I know that can cause some issues but I still get the same result.

I talked with a few people that use this system and the only other thing that I can think of it to restart nginx but can’t find a way to restart it locally

Having the same problem in my Digital Ocean droplet.

TASK [deploy : Reload php-fpm] *************************************************
System info:
  Ansible 2.0.0.2; Darwin
  Trellis at "Fix #569 - Only skip subdomains for non-www domains"

reload: Unknown instance:
fatal: [###.###.###.###]: FAILED! => {"changed": true, "cmd": "sudo service php7.0-fpm reload", "delta": "0:00:00.018489", "end": "2016-05-09 21:50:31.568305", "failed": true, "rc": 1, "start": "2016-05-09 21:50:31.549816", "stderr": "reload: Unknown instance: ", "stdout": "", "stdout_lines": [], "warnings": []}

I’ve been all the morning browsing for an answer outside the forum without success.

Yeah I’m in the same boat here. All my other boxes work just fine except for the new one I created today

This is my story too. A box I created last week works fine. A different box I created today hits the same bad gateway on vagrant up.

@nickrttn, my /var/log/syslog looks like yours.

I’m going to look at GitHub and see if I can pull the previous version of trellis and test it again. I will post again shortly to let you know what I find out

A couple of mine (with example.dev subbed in):

2016/05/09 21:13:14 [error] 1272#1272: *2 connect() to unix:/var/run/php-fpm-wordpress.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.50.1, server: example.dev, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-wordpress.sock:", host: "example.dev"
2016/05/09 21:13:14 [error] 1272#1272: *2 connect() to unix:/var/run/php-fpm-wordpress.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.50.1, server: example.dev, request: "GET /favicon.ico HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-wordpress.sock:", host: "example.dev", referrer: "https://example.dev/"

the last release was 28 days ago. So it doesn’t seem like a recent update would be causing this