Posted by Vince Wadhwani on May 17, 2008

Do yourself a favor, if you get a 502 error using the fastcgi script for nginx, check your /var/log/nginx/error.log file. If you see something that looks like this:

2624#0: *11 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xx.xxx.xxx.xx server: foo.com, URL: "/", upstream: "fastcgi://127.0.0.1:8888", host: "foo.com"

Then make sure you have this line in your php fastcgi_script:

FCGI_WEB_SERVER_ADDRS="127.0.0.1"

That'll save you a whole lot of head scratching and googling.