- 启动
Nginx
报错:nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
- 原因是端口
8080
被使用了,需要换个端口,或者停用掉之前的8080
端口在重新启用服务器。
Mac 系统
- 方式一:
Nginx
将占用的端口换成别的端口 - 方式二:通过命令查看是什么程序占用
8080
端口
$ sudo lsof -i tcp:8080
dengzemiaodeMacBook-Pro:~ dengzemiao$ sudo lsof -i tcp:8080 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Google 391 dengzemiao 24u IPv4 0xac798c597943e7a7 0t0 TCP localhost:55756->localhost:http-alt (ESTABLISHED) Google 391 dengzemiao 27u IPv4 0xac798c5982fee7a7 0t0 TCP 10.0.91.252:55757->10.0.91.252:http-alt (ESTABLISHED) Google 391 dengzemiao 37u IPv4 0xac798c5982f327a7 0t0 TCP localhost:60006->localhost:http-alt (ESTABLISHED) Google 391 dengzemiao 46u IPv4 0xac798c597b415127 0t0 TCP localhost:61210->localhost:http-alt (ESTABLISHED) QQ 722 dengzemiao 14u IPv4 0xac798c5982f50127 0t0 TCP 10.0.91.252:53674->153.3.50.86:http-alt (ESTABLISHED) QQ 722 dengzemiao 16u IPv4 0xac798c5982f50127 0t0 TCP 10.0.91.252:53674->153.3.50.86:http-alt (ESTABLISHED) node 4074 dengzemiao 25u IPv4 0xac798c5984169da7 0t0 TCP *:http-alt (LISTEN) node 4074 dengzemiao 47u IPv4 0xac798c5982ff0427 0t0 TCP localhost:http-alt->localhost:60006 (ESTABLISHED) node 4074 dengzemiao 48u IPv4 0xac798c5978f5f127 0t0 TCP localhost:http-alt->localhost:61210 (ESTABLISHED) node 4074 dengzemiao 54u IPv4 0xac798c598003caa7 0t0 TCP localhost:http-alt->localhost:55756 (ESTABLISHED) node 4074 dengzemiao 55u IPv4 0xac798c5978f627a7 0t0 TCP 10.0.91.252:http-alt->10.0.91.252:55757 (ESTABLISHED)
输出发现有 Google
、QQ
、node
占用着 8080
端口。
如果不是什么特殊的程序,直接通过命令移除一下
$ sudo kill PID 例如: $ sudo kill 391 也可以同时清理多个PID: $ sudo kill 391 722 4074
移除之后在运行 $ nginx
再次启动,如果有特殊软件或者不知道该不该关,那就 nginx
先换个端口用也一样。