502 bad gateway error with php5-fpm on Debian 7

GASPARD Kévin list-reader at koshie.fr
Thu Feb 21 09:26:22 UTC 2013

> Hi there,
>> >Looking at your config file, plus every file include'd in it, can you
>> >see which one server{} block is used for this request? (You'll need
>> >to look at all of the "listen" directives first, and then all of the
>> >"server_name" directives in the server{}s with the "listen" that best
>> >matches the incoming ip:port.)
>> >
>> >What fastcgi_pass line is used in that one server{} block?
>> I've do a grep -R 'listen' /etc/nginx/conf.d/ and every vhost
>> configuration file have two lines, exactly the same:
>>         listen      80;
>>         listen      443 ssl;
> Ok, since all of the "listen" lines are the same, then the server{}
> that is chosen depends on the host name used in the test request.
> 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:  

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

> And which vhost configuration file has the matching server_name
> directive? If there is no exact match, then the first regex match is
> used. If there is none, then the default server{} is used. Which exactly
> is "the first regex" may not be immediately obvious if there are some
> in different files.

Logically, this is the vhost configuration file for  

server {
	listen	    80;
	listen	    443 ssl;
	# server_name;
	server_name	blog.koshie.fr www.blog.koshie.fr;
	root        /var/www/koshie.fr/blog/wordpress;
	msie_padding on;
	ssl_session_timeout  5m;

	ssl_protocols  SSLv2 SSLv3 TLSv1;
	ssl_ciphers  HIGH:!aNULL:!MD5;
	ssl_prefer_server_ciphers   on;

	error_log	/var/log/nginx/error.log;
	access_log	/var/log/nginx/access.log;

	# index         index.php;
	# fastcgi_index index.php;

	client_max_body_size      8M;
	client_body_buffer_size 256K;

         location ~ \.php$ {
                 include fastcgi_params;

                 # Assuming php-fastcgi running on localhost port 9000
#                fastcgi_pass;
		fastcgi_pass unix:/var/run/php5-fpm.sock;
                 fastcgi_param SCRIPT_FILENAME  

                 fastcgi_connect_timeout 60;
                 fastcgi_send_timeout 180;
                 fastcgi_read_timeout 180;
                 fastcgi_buffer_size 128k;
                 fastcgi_buffers 4 256k;
                 fastcgi_busy_buffers_size 256k;
                 fastcgi_temp_file_write_size 256k;
                 fastcgi_intercept_errors on;


>> I'm sorry but I'm not sure to understand why you are asking me to do  
>> and I
>> given you what I can. If I miss something can you point me on the good  
>> way
>> please?
> The problem you report is consistent with the log output you showed.
> But the configuration you showed is not consistent with that log output.
> So something is unexpected.
> 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:

2013/02/21 09:37:35 [error] 3631#0: *1476 connect() failed (111:  
Connection refused) while connecting to upstream, client:,  
server: island.koshie.fr, request: "GET /wp-admin/info.php HTTP/1.1",  
upstream: "fastcgi://", host: "blog.koshie.fr"
2013/02/21 09:37:35 [debug] 3631#0: timer delta: 1
2013/02/21 09:37:35 [debug] 3631#0: posted events 0000000000801CA0
2013/02/21 09:37:35 [debug] 3631#0: posted event 0000000000801CA0
2013/02/21 09:37:35 [debug] 3631#0: posted event 0000000000000000
2013/02/21 09:37:35 [debug] 3631#0: worker cycle
2013/02/21 09:37:35 [debug] 3631#0: epoll timer: 65000

I've copied /etc/nginx/conf.d/ to /etc/nginx/conf.d.backup/, removed files  
into /etc/nginx/conf.d/ and moved /etc/nginx/conf.d/koshie.fr.conf and  
/etc/nginx/conf.d/blog.koshie.fr.conf to /etc/nginx/conf.d/ (because  
unless the both conf I has an error... With squid ! I don't get it, I've  
no squid on my desktop or my server, anyway... I think it's maybe related  
to the fact koshie.fr is the main domain?), restarted nginx and koshie.fr  
works, but blog.koshie.fr/wordpress/info.php gimme again a 502. This is  
the log for this request:

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"
2013/02/21 10:21:22 [debug] 1097#0: timer delta: 0
2013/02/21 10:21:22 [debug] 1097#0: posted events 00000000007299F0
2013/02/21 10:21:22 [debug] 1097#0: posted event 00000000007299F0
2013/02/21 10:21:22 [debug] 1097#0: posted event 0000000000000000
2013/02/21 10:21:22 [debug] 1097#0: worker cycle
2013/02/21 10:21:22 [debug] 1097#0: epoll timer: 65000

> If it still fails, then you have a simpler test case to work from.

What is this test case please?

Cordially, Koshie

More information about the nginx mailing list