nginx启动失败(bind() to 0.0.0.0:80 failed,An attempt was made to access a socket in ...)
nginx 不能启动,报错如下
该错误 实在 nginx 的 logs 下的 errorr.log 中查看2018/12/24 10:29:15 [emerg] 14940#3232: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
1. 通过 cmd 命令查看 80 端口的占用情况
输入命令: netstat -aon|findstr "80"
C:\Users\Administrator>netstat -aon|findstr "80"
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 17368
TCP 0.0.0.0:1555 0.0.0.0:0 LISTENING 800
TCP 0.0.0.0:8081 0.0.0.0:0 LISTENING 18528
TCP 0.0.0.0:54021 0.0.0.0:0 LISTENING 3480
TCP 127.0.0.1:80 127.0.0.1:23924 FIN_WAIT_2 17368
TCP 127.0.0.1:80 127.0.0.1:23930 FIN_WAIT_2 17368
TCP 127.0.0.1:80 127.0.0.1:23932 FIN_WAIT_2 17368
TCP 127.0.0.1:80 127.0.0.1:23937 FIN_WAIT_2 17368
2. 查看 17368 端口 对应的任务
输入命令: tasklist|findstr "17368"
C:\Users\Administrator>tasklist|findstr "17368"
nginx.exe 17368 Console 2 2,260 K
因为我这里已经改完了, 所以 看见的是 nginx 任务
3. 干掉对应的 任务即可
总结
- 事实上,我通过以上方步骤,我发现我的端口占用 是 System 占用的, 但是我没敢直接干掉 这个任务,我突然想到可能是 IIS 服务 原因。
果不其然, 这个 IIS 服务在每次 强制更新后就会 监听 80 端口
右击 — 停止 即可
- 还遇到过, eclipse 启动了 一个80端口的 web服务,导致上述错误的出现
总之, 出现错误的时候,先看看 1. iis 是不是开启了 2. 自己是否有 80 端口的web 项目