问题:connect()failed(111:Connectionrefused)whileconnectingtoupstream
问题描述:
创新互联公司主营洋县网站建设的网络公司,主营网站建设方案,app软件开发公司,洋县h5微信小程序定制开发搭建,洋县网站营销推广欢迎洋县等地区企业咨询
服务器重启之后,服务器也正常运行,发现网站访问不了,后来查看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',来查看. [root@dev ~]# 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>
新闻名称:问题:connect()failed(111:Connectionrefused)whileconnectingtoupstream
新闻来源:http://scjbc.cn/article/peppep.html