Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke

时间:2024-03-25 08:00:22

错误原因:指定的端口2220已被其他进程占用。

解决方案:

cmd进入命令行,输入以下命令

1. 查看端口占用情况

netstat -aon | findstr :2220

可以看到所有关于2220端口的进程

Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke

 2. 查看占用的应用或服务

分别有pid为19112和1968两个进程,占用2220端口,分别找到对应的应用:

tasklist|findstr "19112"

tasklist|findstr "1968"

看到应用分别为:

Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke

Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke

3. 结束占用端口的服务和应用

启动任务管理器,找到相应应用和服务,结束掉。

停止服务的过程如下图:

注:此处服务并不是我这次问题要关闭的服务,按照pid在服务列表中没有找到node.exe。

Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke

服务列表中没有我要结束的node相关服务,没有19112的pid。于是我查看了一下进程列表,没找到node.exe,但找到了nginx.exe。于是先结束了nginx.exe。

Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke

对于pid为19112的node.exe,后想起来我正打开着VSCODE,执行过npm命令,于是把VSCODE关掉。再执行 netstat -aon | findstr :2220,已经没有19112和1968。

重新在命令行执行nginx,服务成功开启,不报错。

Nginx启动报错:nginx: [emerg] bind() to 0.0.0.0:2220 failed (10013: An attempt was made to access a socke