502 errors in parts of site: #35

DoctorGonz opened this Issue Mar 13, 2012 · 7 comments


None yet

8 participants


Dear perusio, using your full setup with a few modifications, i get a super lightning fast site, but in some parts of it i receive 502 errors (which i don't get with plain install). my setup is nginx+php-fpm+apc+boost, and by using included drupal_boost the site loads fine, but goes bork in:

  • a few books and their childs
  • drupal commerce: adding an item to the cart, or any part of checkout process.
    when clicking on the above i immediately receive 502 error, but the rest of the site is still operational. I have looked inside nginx.conf, drupal_boost, php and fastcgi_drupal.conf but nothin managed to get me over this issue. I would really like to use this setup, since on all other parts it is lightning.
perusio commented Mar 13, 2012


Can you provide a debug log tracing the requests that generate the 502? Paste it here or in a paste bin somewhere.



I am also getting seemingly random 502 Bad Gateway errors.

I'm using upstream_phpcgi_unix.conf and have only modified the names of the sockets (I changed them from zwei... to zero, one and two).

My error log is showing errors like the following
2012/05/12 06:01:01 [error] 18024#0: *1303790 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:, server: megagames.com, request: "GET /admin/content/orphan-game-entries HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm-zero.sock:", host: "megagames.com", referrer: "http://megagames.com/admin/content"
2012/05/12 06:01:01 [error] 18024#0: *1303790 no live upstreams while connecting to upstream, client:, server: megagames.com, request: "GET /admin/content/orphan-game-entries HTTP/1.1", upstream: "fastcgi://phpcgi:", host: "megagames.com", referrer: "http://megagames.com/admin/content"

In most cases, only the first error occurs. In these cases, if it's only a connection reset, the page loads fine -- I'm assuming that's because nginx falls over to another socket which succeeds.

In the case where the second error occurs, you can see that the socket is in fact wrong:
upstream: "fastcgi://phpcgi:"

This is a non existent socket, and in fact nginx croaks here with the 502. Hitting refresh in the browser will then load the page successfully, I'm assuming, again, because nginx gets a good unix socket on the following attempt.

My Nginx was not compiled with debug log enabled, and we're live now, so I can't recompile to run a trace, unfortunately.

Fidelix commented Jul 23, 2012

Try to edit your upstream and comment keepalive.
Edit your nginx servers and comment fastcgi_keep_conn.

This fixed it for me.


@perusio this issue seems to be still happening with the actual configuration.
The solution proposed by @Fidelix at #35 (comment) fixed it for me.


Unfortunately, I troubleshooted this issue for months. Literally months. I modified just about every parameter (good forum here about related possible issues: https://groups.drupal.org/node/229898#comment-1072193 ) .... Ultimately, I had to resort to turning off keep alive connections (comment fastcgi_keep_conn like @Fidelix mentions). I wish I could have taken advantage of this feature of Nginx, but I just can't get it worked out. I can post further logs here; @aaroncraig pretty much nailed exactly what my issues always are (same log errors too). And same description of how it always happened too where refresh is fine because nginx connects again to a new worker I presume.



Please check to make sure you are not enabling opcache.so or any other cache twice.

ttenz commented Jul 19, 2015

I have turn on tcp and now all is ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment