Linux nginx: [emerg] bind() to [::]:80 failed

WechatIMG651.jpeg

环境

  • Ubuntu 16.04.7

  • Nginx 1.10.3

问题

  • 启动 nginx
$ service nginx start
Job for nginx.service failed because the control process exited with error code. 
See "systemctl status nginx.service" and "journalctl -xe" for details.

启动 nginx 服务器,返回报错如上。

  • 查看 nginx 状态
$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2022-01-25 16:31:39 CST; 1min 3s ago
  Process: 27381 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 27380 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/

Jan 25 16:31:38 VM-2-14-ubuntu nginx[27381]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in
Jan 25 16:31:38 VM-2-14-ubuntu nginx[27381]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already
Jan 25 16:31:38 VM-2-14-ubuntu nginx[27381]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in
Jan 25 16:31:39 VM-2-14-ubuntu nginx[27381]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already
Jan 25 16:31:39 VM-2-14-ubuntu nginx[27381]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in
Jan 25 16:31:39 VM-2-14-ubuntu nginx[27381]: nginx: [emerg] still could not bind()
Jan 25 16:31:39 VM-2-14-ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 25 16:31:39 VM-2-14-ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy
Jan 25 16:31:39 VM-2-14-ubuntu systemd[1]: nginx.service: Unit entered failed state.
Jan 25 16:31:39 VM-2-14-ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.

查看 nginx 状态,看到具体错误是因为80端口被占用,这意味着 nginx 或其他进程已经使用了80端口。

  • 杀死占用80端口的进程
$ fuser -k 80/tcp
  • 再次启动 nginx
$ service nginx start

可以正常启动!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值