nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream connect()

Posted adhzl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream connect()相关的知识,希望对你有一定的参考价值。

若fpm配置文件中配置如下:

listen = 127.0.0.1:9000

 则对应的nginx.conf中的配置应为:

fastcgi_pass   127.0.0.1:9000;

 此时开启9000端口监听,不会生成sock文件

若fpm中的配置为使用Unix套接字,如下:

listen = /run/php/php7.2-fpm.sock

则对应nginx.conf中的配置应为:

fastcgi_pass   unix:/run/php/php7.2-fpm.sock;

此时9000端口未开启,在/run/php/下生成php7.2-fpm.sock文件

若两者不匹配则nginx启动失败。

若fpm为sock,nginx为127.0.0.1:9000,则会出现以下错误:

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

若fpm未127.0.0.1:9000,nginx为sock,则会出现以下错误:

connect() to unix:/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream

 

 

以上是关于nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream connect()的主要内容,如果未能解决你的问题,请参考以下文章

nginx php-fpm记录php错误日志怎么配置

php-fpm sock文件权限设置

Nginx + Yii app = js,css - net :: ERR_CONNECTION_REFUSED

覆盆子上的 nginx + php-fpm + pidora(fedora)

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

PHP-FPM 和 Nginx:502 错误网关