502 bad gateway error with php5-fpm on Debian 7

Francis Daly francis at daoine.org
Thu Feb 21 13:50:41 UTC 2013

On Thu, Feb 21, 2013 at 10:26:22AM +0100, GASPARD Kévin wrote:

Hi there,

> >So: what is the hostname in the url that you try to get, when you see
> >the 502 error?
> Trying to install a Wordpress, used a info.php page here:  
> http://blog.koshie.fr/wp-admin/info.php

Ok - so the one server{} block that is used is either the one that has
server_name blog.koshie.fr, or is the default one.

> As you can see, there is a 502 Bad Gateway error.

Yes, and that error log shows that:

> 2013/02/21 10:21:22 [error] 1097#0: *5 connect() failed (111: Connection  
> refused) while connecting to upstream, client:, server:  
> koshie.fr, request: "GET /wordpress/info.php HTTP/1.1", upstream:  
> "fastcgi://", host: "blog.koshie.fr"

it is using the server "koshie.fr", not the server
"blog.koshie.fr". Presumably the server "koshie.fr" is the default,
and the server "blog.koshie.fr" does not exist.

So the configuration that is running, is *not* the configuration that
you are showing here.

> Logically, this is the vhost configuration file for  
> http://blog.koshie.fr/wp-admin/info.php:

But based on your later mail, this configuration file does not exist.

If you want to get this configured correctly, your best bet is probably
to simplify the configuration significantly.

Leave /etc/nginx/nginx.conf as it is.

Let /etc/nginx/conf.d have exactly one file in it, this one.

Then run your test and see if it works or fails.

> >Maybe it is simplest if you rename the conf.d directory, then create
> >a new conf.d directory with just one vhost file. Then reload nginx and
> >re-do your test of a php request and see what it says.
> So, above you've the configuration file related to this log error:


That configuration file does not result in this error.

> >If it still fails, then you have a simpler test case to work from.
> What is this test case please?

Your test case is:

* you run "curl -i http://blog.koshie.fr/wordpress/info.php"
* you expect to see some useful content
* you actually see a 502 error.

Then do whatever it takes to get the expected output.

I think that one part of the problem is that you have only half-changed
from an old system to a new system.

You new system has nothing listening on, so any
configuration that mentions that ip:port is broken. It should be removed,
or replaced with the unix socket.

And your new system does not actually include all of the files that you
want it to.

When your nginx starts, it reads exactly one configuration file:

That file then uses "include" to read some other files. Those other
files do not seem to be the ones you want, for some reason.

I suggest: stop nginx. Make sure it is stopped, and not running, and
has nothing listening on port 80 or port 443. Then look at the files
in /etc/nginx/conf.d, and make sure that they are exactly the ones that
you want. Then start nginx, access the info.php url, and see if it works.

Good luck,

Francis Daly        francis at daoine.org

More information about the nginx mailing list