Windows下启动nginx报:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket

解决方法一

(1)查看nginx-1.19.2\logs目录下的error.log,得知报错信息为: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)

(2)按键盘win+r,输入cmd,打开管理员界面

(3)输入netstat -aon|findstr :80,找到端口号为0.0.0.0:80被占用了,查看pid值为4

Windows下启动nginx报:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket

(4)输入tasklist|findstr  "4",找到4端口对应的名称,为 System

Windows下启动nginx报:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket

(5)查看后是System系统占用无法手动终止,原因是SQLServer Reporting Services,停掉这个服务并设置为手动起动即可,启动好nginx后,需重新启动SQLServer Reporting Services

缺点:这种做法每次开机后需重新停掉SQLServer Reporting Services,再启动nginx

解决方法二:

修改nginx.conf下的默认端口号

(1)用记事本打开nginx目录下的nginx.conf文件

(2)按键盘win+r,输入cmd,打开管理员界面,输入netstat -aon|findstr :预期端口号,查看自己的预期端口号是否被占用

(3)修改nginx.conf,后保存

Windows下启动nginx报:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket

(4)在命令提示符下输入nginx -s reload即可(重要一步)

(5)然后命令提示符下输入start nginx

(6)在浏览器localhost:81,如果出现以下页面在修改成功

Windows下启动nginx报:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket