502 Bad Gateway - Nginx Timeout (solved)

I’m running 3 projects on 1 Vagrant box. I was working on a project and suddenly I was hit with a 502 error. The other projects work fine, so I go to investigate:

$ tail -f /srv/www/website.com/logs/website.com.error.log
[error] 11841#0: *6 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:, server: website.dev, request: "GET /wp/wp-cron.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm-wordpress.sock:", host: "website.dev"

After Google-ing the error I find many different answers, none of which seem to pertain to my problem. Some say to make sure the socket exists:

$ ls -la /var/run/ | grep "php5-fpm"
drwxr-xr-x  2 root       root         40 Jul 15 03:58 php5-fpm
-rw-r--r--  1 root       root          5 Jul 15 22:59 php5-fpm.pid
srw-rw----  1 www-data   www-data      0 Jul 15 22:55 php5-fpm-wordpress.sock

Restarting nginx and php5-fpm yields no promising results. I’m not sure what direction to go with this, since I’m not very familiar with configuring nginx or php5-fpm.

Hi @connormfreeman

Does PHP info still return results? If so could it be nginx timeout or memory related if running big cron job? Are you able to reproduce this on another test project? Apart from that wait for people much smarter than me to respond…


Thanks @Craig,

You were right about the timing out issue. I’m using the Widget Logic plugin and I wanted a certain widget in the footer to only appear if the sidebar is not active. Silly me put in the conditional tag is_active_sidebar() and that reproduced the issue after a few refreshes.

1 Like

Awesome @connormfreeman! Glad you got it sorted!

1 Like