欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream

发布时间:2025/3/8 编程问答 26 豆豆
生活随笔 收集整理的这篇文章主要介绍了 nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

安装好nginx,php环境后,配置虚拟主机,结果访问后就报502 gateway,查看日志文件后,显示错误如下:

2019/04/29 16:24:39 [error] 19433#19433: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.52, server: 192.168.1.222, request: "GET / HTTP/1.1"

解决方案,先查看下php-fpm是否启动,然后查看虚拟主机配置中的 root 配置

server {listen 80;server_name 192.168.1.222;charset utf-8;location / {root /data/wwwroot;index index.php index.html index.htm;}location ~ \.php$ {#注意这里root配置与当前server下的root保持一致#我的报错原因是我把root这项给删除root /data/wwwroot;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;} }

然后重启下nginx就可以访问了。

转载于:https://www.cnblogs.com/jkko123/p/10791283.html

总结

以上是生活随笔为你收集整理的nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。