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

最近從新部署了一下應用程序,以後從新運行gunicorn,使用以下命令:python

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

以後出現了一堆錯誤,具體錯誤內容以下:mysql

[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沒有關閉。nginx

查看一下佔用狀況:sql

netstat -tulpn

能夠看到以下內容:app

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

重點是這個內容:ssh

 

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

PID爲4093的程序佔用了8000端口,直接殺掉進程,命令以下:tcp

kill -9 4093

以後再次運行gunicorn,命令以下:ide

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

已經成功運行,截圖以下:spa

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

相關文章
相關標籤/搜索