php nginx:connect() 连接到上游时失败(111:连接被拒绝)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21524373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:13:55  来源:igfitidea点击:

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

nginxfastcgiphp

提问by Tripathi29

Trying to deploy my first portal .

尝试部署我的第一个门户。

I am getting 502 gateway timeout error in browser when i was sending the request through browser

当我通过浏览器发送请求时,我在浏览器中收到 502 网关超时错误

when i checked the logs , i got this error

当我检查日志时,我收到此错误

 2014/02/03 09:00:32 [error] 16607#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 14.159.131.19, server: foo.com, request: "GET HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "22.11.180.154"

is there any problem related to permissions

是否有任何与权限相关的问题

回答by Digital site

I don't think that solution would work anyways because you will see some error message in your error log file.

我认为该解决方案无论如何都行不通,因为您会在错误日志文件中看到一些错误消息。

The solution was a lot easier than what I thought.

解决方案比我想象的要容易得多。

simply, open the following path to your php5-fpm

简单地,打开以下路径到您的php5-fpm

sudo nano /etc/php5/fpm/pool.d/www.conf

or if you're the admin 'root'

或者如果您是管理员“root”

nano /etc/php5/fpm/pool.d/www.conf

Then find this line and uncomment it:

然后找到这一行并取消注释:

listen.allowed_clients = 127.0.0.1

This solution will make you be able to use listen = 127.0.0.1:9000in your vhost blocks

此解决方案将使您能够在 vhost 块中使用listen = 127.0.0.1:9000

like this: fastcgi_pass 127.0.0.1:9000;

像这样:fastcgi_pass 127.0.0.1:9000;

after you make the modifications, all you need is to restart or reload both Nginx and Php5-fpm

进行修改后,您只需要重新启动或重新加载 Nginx 和 Php5-fpm

Php5-fpm

php5-fpm

sudo service php5-fpm restart

or

或者

sudo service php5-fpm reload

Nginx

nginx

sudo service nginx restart

or

或者

sudo service nginx reload

From the comments:

来自评论:

Also comment

还有评论

;listen = /var/run/php5-fpm.sock 

and add

并添加

listen = 9000