[已解决]运行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

posted @ 2018-12-17 13:48  核电站  阅读(5706)  评论(0编辑  收藏  举报