文章内容

2018/6/16 17:45:47,作 者: 黄兵

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

已经成功运行,截图如下:



参考资料:[已解决]运行gunicorn失败:[ERROR] Connection in use 127.0.0.1 8080


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - [已解决]运行gunicorn失败:[ERROR] Connection in use 127.0.0.1 8080

分享到:

发表评论

评论列表

user-ico

微博抽奖活动合集 on 回复 有用(0

有用


user-ico

dddd on 回复 有用(0

抄都抄一样的