[已解決]運行gunicorn失敗:[ERROR] Connection in use 127.0.0.1 8080


最近重新部署了一下應用程序,之后重新運行gunicorn,使用如下命令:

gunicorn -b 0.0.0.0:8000 manage:app --reload

之后出現了一堆錯誤,具體錯誤內容如下:

[2018-06-16 17:04:59 +0800] [24890] [INFO] Starting gunicorn 19.8.1
[2018-06-16 17:04:59 +0800] [24890] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2018-06-16 17:04:59 +0800] [24890] [ERROR] Retrying in 1 second.
[2018-06-16 17:05:00 +0800] [24890] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2018-06-16 17:05:00 +0800] [24890] [ERROR] Retrying in 1 second.
[2018-06-16 17:05:01 +0800] [24890] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2018-06-16 17:05:01 +0800] [24890] [ERROR] Retrying in 1 second.
[2018-06-16 17:05:02 +0800] [24890] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2018-06-16 17:05:02 +0800] [24890] [ERROR] Retrying in 1 second.
[2018-06-16 17:05:03 +0800] [24890] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2018-06-16 17:05:03 +0800] [24890] [ERROR] Retrying in 1 second.
[2018-06-16 17:05:04 +0800] [24890] [ERROR] Can't connect to ('0.0.0.0', 8000)

一直嘗試連接8000端口,這個應該是gunicorn沒有關閉。

查看一下占用情況:

netstat -tulpn

可以看到如下內容:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 16528/beam
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1425/mysqld
tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN 9093/sendmail: MTA:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20372/nginx -g daem
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 16621/epmd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1004/sshd
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 16528/beam
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 9093/sendmail: MTA:
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 22627/python3.5
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 11530/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4093/zabbix_server
tcp6 0 0 :::5672 :::* LISTEN 16528/beam
tcp6 0 0 :::80 :::* LISTEN 20372/nginx -g daem
tcp6 0 0 :::4369 :::* LISTEN 16621/epmd
tcp6 0 0 :::1017 :::* LISTEN 4564/IntelliJIDEALi
tcp6 0 0 :::5050 :::* LISTEN 29792/dotnet
tcp6 0 0 :::10050 :::* LISTEN 11530/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 4093/zabbix_server
udp 0 0 10.104.102.216:123 0.0.0.0:* 1195/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 1195/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 1195/ntpd
udp 0 0 127.0.0.1:161 0.0.0.0:* 1239/snmpd
udp 0 0 0.0.0.0:47718 0.0.0.0:* 1239/snmpd
udp6 0 0 :::123 :::* 1195/ntpd

重點是這個內容:

 

tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4093/zabbix_server

PID為4093的程序占用了8000端口,直接殺掉進程,命令如下:

kill -9 4093

之后再次運行gunicorn,命令如下:

gunicorn -b 0.0.0.0:8000 manage:app --reload

已經成功運行,截圖如下:

 https://pdf-lib.org/Home/Details/5262


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM