nginx 不停的报 could not bind() 的 error log,实际又不影响访问,是神马情况?

2017-07-07 23:32:23 +08:00
 rogwan
一段时间发现某个文件夹怎么那么大,一看才发现是 nginx 的 error.log 已经 6.5G 啦,因为访问都正常,没发现异常情况,就是不断的出现下面的重复 error log

2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:8888 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:99 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:8888 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:99 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:8888 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:99 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:8888 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:99 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:80 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to [::]:443 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:8888 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: bind() to 0.0.0.0:99 failed (98: Address already in use)
2017/07/02 10:43:27 [emerg] 1766#0: still could not bind()

上面的这些端口 80 99 8888 443 都是在正常访问的状态,不知道为什么还要记录这样的 error log?
4008 次点击
所在节点    问与答
15 条回复
wellsc
2017-07-08 00:20:57 +08:00
sudo lsof -i tcp:80 试试看
fuxkcsdn
2017-07-08 00:23:26 +08:00
是不是启动了多个 nginx ? ps 找找看
johnlui
2017-07-08 00:30:26 +08:00
目测是启动了多个 master 进程
ETiV
2017-07-08 03:40:28 +08:00
装 gitlab 了?
cxbig
2017-07-08 04:20:52 +08:00
master 进程有多个 +1
ghostheaven
2017-07-08 06:32:57 +08:00
0.0.0.0 是绑定本机所有 ip,可能有一个 ip 的 80 和 443 被别的占用了
rogwan
2017-07-08 08:48:32 +08:00
@wellsc

查看了下,是 ipv4 和 ipv6 抢抢同一个端口造成的?
# sudo lsof -i tcp:80
nginx 1306 root 9u IPv4 10290 0t0 TCP *:http (LISTEN)
nginx 1306 root 10u IPv6 10291 0t0 TCP *:http (LISTEN)
nginx 1312 nobody 9u IPv4 10290 0t0 TCP *:http (LISTEN)
nginx 1312 nobody 10u IPv6 10291 0t0 TCP *:http (LISTEN)
rogwan
2017-07-08 08:51:49 +08:00
@ETiV

确实是装了 gitlab,但是我分配了一个专门的 9596 端口,没有出现上面的冲突 log 中呀
kn007
2017-07-08 11:24:48 +08:00
ipv4 和 ipv6 同事监听 80,要以这种方式:

listen 80;
listen [::]:80 ipv6only=on;
rogwan
2017-07-08 11:54:38 +08:00
@kn007 是这样写的,这两个没冲突。

@fuxkcsdn
@johnlui

这个机器上跑了一个 nginx web,还跑了一个 gitlab,看了进程记录显示,gitlab 里面也有一个 nginx 的 master 进程在跑,虽然指定了端口给 gitlab 用,但估计 gitlab 的 nginx 还默认监听了其他端口,造成已经被 nginx web 占用的端口就 bind 不了。
wellsc
2017-07-08 12:01:39 +08:00
@rogwan 应该是同时跑了两个人 Nginx 造成的 ,pwdx pid 看一下分别是那两个 nginx
johnlui
2017-07-08 12:03:38 +08:00
netstat -tulpn

一看便知
iConnect
2017-07-08 12:15:08 +08:00
@johnlui 这个是看在监听状态的端口,楼主说的没有 bind 上报错,那就看不到了

@rogwan 看看这个 https://stackoverflow.com/questions/25393370/gitlab-nginx-problems-nginx-emerg-bind-to-0-0-0-080-failed-98-address
johnlui
2017-07-08 14:01:17 +08:00
@iConnect bind 上报错是因为别的进程已经监听了呀。。。用这个命令可以准确的找到是哪个进程监听了。
ETiV
2017-07-08 14:26:51 +08:00
LZ 貌似已经解决了?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/373842

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX