Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx connect() failed error

Tags:

php

nginx

server

I don't know why I got this error every time I tried to open the page:

2013/04/06 17:52:19 [error] 5040#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080"
like image 334
Hazem Hagrass Avatar asked Apr 06 '13 15:04

Hazem Hagrass


3 Answers

I resolved it, it was a configuration file issue, I added:

location ~ .php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}
like image 184
Hazem Hagrass Avatar answered Nov 11 '22 05:11

Hazem Hagrass


For me the problem was my php-fpm service wasn't running. You can check it by running:

service php-fpm status

and start it by running

service php-fpm start

Sometimes php-fpm might have broken instances running, preventing a restart. This command is a clean way to clear them out and restart php-fpm

killall -9 php-fpm; service php-fpm restart
like image 18
ContextSwitch Avatar answered Nov 11 '22 06:11

ContextSwitch


update your configurations as mentioned before:

location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

but don't forget to restart both nginx server and php-fpm after updating

sudo /etc/init.d/nginx restart
sudo /etc/init.d/php-fpm restart
like image 3
user3111020 Avatar answered Nov 11 '22 04:11

user3111020