欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

程序员文章站 2022-05-24 18:06:15
...

nginx启动失败

nginx启动失败(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))


在Windows安装了下nginx启动失败,报错nginx: [emerg] 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)

nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

原来是nginx listen的80端口被占用

1、cmd输入命令netstat -aon|findstr “80”

打开cmd

输入命令: netstat -aon|findstr "80" 查询谁占了80端口

C:\Users\x1c>netstat -aon|findstr "80"
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       7532
  TCP    0.0.0.0:902            0.0.0.0:0              LISTENING       4780
  TCP    0.0.0.0:912            0.0.0.0:0              LISTENING       4780
  TCP    0.0.0.0:6800           0.0.0.0:0              LISTENING       10844
  TCP    0.0.0.0:8082           0.0.0.0:0              LISTENING       12892
  TCP    127.0.0.1:10808        0.0.0.0:0              LISTENING       13880

2.、查看80端口 7532对应的任务

输入命令: tasklist|findstr "7532"

C:\Users\x1c>tasklist|findstr "7532"
nginx.exe                     7532 Console                    1      7,440 K

原来是我之前打开过nginx程序占用了80端口,那就去关掉

3、结束对应任务

nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

结束任务7532.

4、去启动nginx

打开cmd,去对应的nginx目录,启动nginx

nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

浏览器输入localhost
nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)
启动成功

或者是 System 占用的80端口

C:\Users\x1c>netstat -aon|findstr "80"
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:902            0.0.0.0:0              LISTENING       4780
  TCP    0.0.0.0:912            0.0.0.0:0              LISTENING       4780
  TCP    0.0.0.0:6800           0.0.0.0:0              LISTENING       10844
  TCP    0.0.0.0:8082           0.0.0.0:0              LISTENING       12892
  TCP    127.0.0.1:6804         127.0.0.1:3462         TIME_WAIT       0
  TCP    127.0.0.1:10808        0.0.0.0:0              LISTENING       13880
  TCP    192.168.124.12:6135    221.181.72.102:80      CLOSE_WAIT      15692
C:\Users\x1c>tasklist|findstr "80"
smss.exe                       380 Services                   0        708 K
csrss.exe                      580 Services                   0      3,508 K
svchost.exe                    888 Services                   0     32,580 K
winlogon.exe                   880 Console                    1      7,164 K
LPlatSvc.exe                  1780 Services                   0      4,236 K
ibmpmsvc.exe                  1796 Services                   0      4,080 K
igfxCUIService.exe            2300 Services                   0      5,380 K
svchost.exe                   2800 Services                   0      7,188 K
svchost.exe                   3284 Console                    1     16,808 K
vmware-authd.exe              4780 Services                   0      8,056 K

这个有可能是 IIS服务 占用80端口 ,那就去尝试关闭IIS服务。

启动IIS服务 net start w3svc

关闭IIS服务 net start w3svc

以管理员身份运行cmd,

输入命令net start w3svc

nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

关闭IIS服务了,那就可以去尝试启动下nginx,看是否是IIS占用了80端口
nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

可以执行nginx.exe 那就是IIS占用了80端口。