nginx connect() failed (111: Connection refused) while connecting to upstream

With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>

After the company’s website moved to the new server, it was found that the site could not be accessed. There was a prompt 502 in the network. After checking the relevant server configuration, it felt that there was no problem. After testing, it was found that non PHP files such as TXT, HTML, etc. could be accessed directly, that is, PHP could not be accessed. It was preliminarily concluded that PHP FPM was not installed or started

first of all, judge whether PHP FPM has been installed. If not, you need to install PHP FPM first. You can install parameters related to PHP FPM< after confirming that PHP FPM has been installed on the server, check whether it has been started or restarted directly: after the server is installed, check whether it has been started[ [email protected] /]#/ usr/local/PHP/SBIN/PHP FPM start
after startup, restart nginx:

after startup[ [email protected] /]#Service nginx restart

and then refresh the website page, but it didn’t succeed, It’s still wrong

at this time, we first check the error log error.log, and find that there are all the same error reports:

connect() failed (111: connection reused) while connecting to upstream fastcgi://127.0.0.1 : 9000…

the prompt means that port 9000 can’t be connected, which is strange. In fact, in the server configured with nginx, Most of them should be configured with 127.0.0.1:9000 as the distribution port< now we need to check whether there is a monitoring port: we need to check whether there is a monitoring port[ [email protected] /]#Netstat – ant | grep 9000 found that it did not listen, but in fact our PHP FPM has been started, so what should we do now< let’s check the configuration in php-fpm.conf: [ [email protected] /]#VIM/usr/local/PHP/etc/PHP FPM. Conf
find listen:

& lt; value name=”listen_ address”>/ tmp/php-cgi.sock</ value>

at this time, we need to make corresponding modification according to the listen address of the configuration file:

location ~ \. PHP ${
fastcgi_ pass 127.0.0.1:9000;
fastcgi_ index index.php;
fastcgi_ param SCRIPT_ FILENAME $document_ root$fastcgi_ script_ name;
include fastcgi_ params;< }
changed to:

location ~ \. PHP ${
fastcgi_ pass unix:/tmp/php-cgi.sock;
fastcgi_ index index.php;
fastcgi_ param SCRIPT_ FILENAME $document_ root$fastcgi_ script_ name;
include fastcgi_ params;
}

Restart nginx. The visit was successful<
– –
Author: ljihe
source: CSDN
original text: https://blog.csdn.net/ljihe/article/details/78025133
Copyright notice: This article is the original article of the blogger, please attach the blog link if you reprint it

Similar Posts: