NGINX 启动失效 [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
1、systemctl start nginx 启动 NGINX 报错 , 使用 systemctl status nginx 看信息
[root@localhost /]# systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
[root@localhost /]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2020-06-30 18:32:55 CST; 7s ago
Process: 8109 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 8107 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 8105 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 1750 (code=killed, signal=KILL)
Memory: 11.2M
CGroup: /system.slice/nginx.service
├─1751 nginx: worker process
├─1752 nginx: worker process
├─1753 nginx: worker process
├─1754 nginx: worker process
├─1755 nginx: worker process
├─1756 nginx: worker process
├─1757 nginx: worker process
└─1758 nginx: worker process
Jun 30 18:32:54 localhost.localdomain nginx[8109]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jun 30 18:32:54 localhost.localdomain nginx[8109]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jun 30 18:32:54 localhost.localdomain nginx[8109]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 30 18:32:54 localhost.localdomain nginx[8109]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jun 30 18:32:54 localhost.localdomain nginx[8109]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jun 30 18:32:55 localhost.localdomain nginx[8109]: nginx: [emerg] still could not bind()
Jun 30 18:32:55 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Jun 30 18:32:55 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jun 30 18:32:55 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Jun 30 18:32:55 localhost.localdomain systemd[1]: nginx.service failed.
地址被占用,可能nginx服务卡死了,导致端口占用,出现此错误
2、使用: **lsof -i:80 ** 查看哪个程序在使用 80 端口
[root@localhost /]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1751 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1751 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1752 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1752 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1753 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1753 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1754 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1754 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1755 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1755 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1756 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1756 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1757 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1757 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
nginx 1758 root 8u IPv4 29257 0t0 TCP *:http (LISTEN)
nginx 1758 root 10u IPv6 29259 0t0 TCP *:http (LISTEN)
是 NGINX 自己占用,使用 kill -9 pid 杀死已运行的NGINX
kill -9 1751
.....
3、使用 systemctl start nginx 重启 NGINX 服务
结束

浙公网安备 33010602011771号