溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

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

發(fā)布時(shí)間:2020-06-07 10:52:37 來源:網(wǎng)絡(luò) 閱讀:11772 作者:Benyod 欄目:web開發(fā)

問題描述:

    服務(wù)器重啟之后,服務(wù)器也正常運(yùn)行,發(fā)現(xiàn)網(wǎng)站訪問不了,后來查看nginx 錯(cuò)誤日志(/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,發(fā)現(xiàn)類似不少的問題,就整理了一下,基本上有以下三個(gè)原因造成這個(gè)問題的原因:

>>>php-fpm沒有安裝


>>>php-fpm沒有運(yùn)行

可以用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           
......

如果沒有運(yùn)行,使用啟動(dòng):
/etc/init.d/php-fpm start


>>>php-fpm隊(duì)列滿了

php-fpm.conf (/etc/php-fpm.conf)配置文件pm.max_children修改大一點(diǎn),重啟php-fpm并觀察日志情況
cd


也看到一個(gè),端口被占用的情況:

nginx的error日志里經(jīng)常報(bào)錯(cuò)

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)

偶爾出現(xiàn)
[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個(gè)解決辦法
1 在nginx.conf中換個(gè)php的端口試試
2 實(shí)在不行還有sock方式。
3 殺死那個(gè)占用9000端口的程序。


2>

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI