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

问题描述:

服务器重启之后,服务器也正常运行,发现网站访问不了,后来查看nginx 错误日志(/var/log/nginx/error.log )

2016/05/13 10:47:32 [error] 7688#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: ****.****.****.33, server: , request: "GET url HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "****.leyue.com.cn:22080"

后来google,发现类似不少的问题,就整理了一下,基本上有以下三个原因造成这个问题的原因:

>>>php-fpm没有安装

>>>php-fpm没有运行

可以用ps aux | grep ‘php-fpm‘,来查看.
[[email protected] ~]# ps aux | grep ‘php-fpm‘
root      4570  0.0  0.1 612024  7820 ?        Ss   May12   0:04 php-fpm: master process (/etc/php-fpm.conf)
fpmport   4571  0.0  0.0 611620  5864 ?        S    May12   0:00 php-fpm: pool port           
fpmport   4572  0.0  0.0 611620  5892 ?        S    May12   0:00 php-fpm: pool port           
......

如果没有运行,使用启动:
/etc/init.d/php-fpm start

>>>php-fpm队列满了

php-fpm.conf (/etc/php-fpm.conf)配置文件pm.max_children修改大一点,重启php-fpm并观察日志情况
cd

也看到一个,端口被占用的情况:

nginx的error日志里经常报错

2011/09/27 13:03:47 [error] 17493#0: *7438996 connect() failed (111: Connection refused) while connecting to upstream, client: 180.168.109.106, server: mysite.com, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mysite.com"
2011/09/27 13:03:48 [error] 17493#0: *7438996 connect() failed (111: Connection refused) while connecting to upstream, client: 180.168.109.106, server: mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mysite.com"
2011/09/27 13:03:49 [error] 17493#0: *7438996 connect() failed (111: Connection refused) while connecting to upstream, client: 180.168.109.106, server: mysite.com, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mysite.com"

php-fpm的 ERROR级别的日志是, 

[27-Sep-2011 12:08:02] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[27-Sep-2011 12:30:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[27-Sep-2011 12:40:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[27-Sep-2011 12:50:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[27-Sep-2011 12:57:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[27-Sep-2011 13:03:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[27-Sep-2011 13:03:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)

偶尔出现
[26-Sep-2011 17:48:24] ERROR: ptrace(PEEKDATA) failed: Input/output error (5)
[26-Sep-2011 17:49:04] ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
[26-Sep-2011 17:49:32] ERROR: ptrace(PEEKDATA) failed: Input/output error (5)
[26-Sep-2011 17:49:33] ERROR: ptrace(PEEKDATA) failed: Input/output error (5)
[26-Sep-2011 17:49:42] ERROR: ptrace(PEEKDATA) failed: Input/output error (5)

原因:

ERROR: bind() for address ‘127.0.0.1:9000‘ failed: Address already in use (98)
很明显9000端口被占用。
3个解决办法
1 在nginx.conf中换个php的端口试试
2 实在不行还有sock方式。
3 杀死那个占用9000端口的程序。

2>

时间: 2024-08-12 15:28:14

问题:connect() failed (111: Connection refused) while connecting to upstream的相关文章

nginx connect() failed (111: Connection refused) while connecting to upstream,请求无响应错误

2015/01/02 16:01:36 [error] 29002#0: *714153 connect() failed (111: Connection refused) while connecting to upstream, client: 172.16.3.32, server: bizorder.qianbao666.com, request: "POST /api/queryOrder/orderList HTTP/1.1", upstream: "http:

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

配置好lamp后,在浏览器中运行程序后,出现上面的错误. 转自:http://www.xuejiehome.com/blread-1828.html I'm experiencing 502 gateway errors when accessing a PHP file in a directory (http://domain.com/dev/index.php), the logs simply says this: 2011/09/30 23:47:54 [error] 31160#0:

nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream connect() to unix:/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream

若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端口未开启,在/

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

新lnmp环境调试项目时,nginx报错如下: 解决: 发现php-fpm.conf是以套接字方式通信,而nginx是以端口方式通信,见下图: 将nginx.conf修改为如下,重新reload即可 原文地址:https://www.cnblogs.com/godfather007/p/10596265.html

【nginx】kevent() reported that connect() failed (61: Connection refused)

访问php页面时,nginx报如下错误 2014/12/25 12:36:13 [error] 3846#0: *3 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "f

Android客户端连接tomcat时出错:connect failed: ECONNREFUSED (Connection refused)

public static final String BASE_URL = "http://127.0.0.1:8090/HelloWord/"...; 会抛异常Caused by: libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused) 解决方法: String url = "http://127.0.0.1:8090/HelloWord/"...;  修改成 pub

android 中Network error IOException: failed to connect to /127.0.0.1 (port 1433): connect failed: ECONNREFUSED (Connection refused)

下面对android中出现的Network error IOException: failed to connect to /127.0.0.1 (port 1433): 做一下总结: 当用android程序调用本地的sqlserver的时候,当连接ip写成127.0.0.1的时候,怎么都连不通,出现以下的错误信息: 感觉好像是代码有问题或者是清单文件中某个权限忘加了,其实不是这样的.原来模拟器默认把127.0.0.1和localhost当做本身了,在模拟器上可以用10.0.2.2代替127.0

如何解决远程连接mysql出现Can’t connect to MySQL server on (111 “Connection refused”)的问题

如何解决远程连接mysql出现Can't connect to MySQL server on (111 "Connection refused")的问题 开放Mysql的远程连接 在服务器上登录mysql,然后执行以下的命令. 登录mysql: /usr/local/mysql-5.6/bin/mysql -u root -p 执行赋权的命令: MySQL> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '1234

mariadb报:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused")

我这边移除了mysql.sock文件后,重启服务就成功了. 还有一种情况,就是加入galera后,可能是server.cnf配置信息出了问题导致的,修改后,重新运行galera即可,数据库就可以启动成功了. mariadb报:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused") 原文地址:h