nginx启动服务提示98: Address already in use错误的解决
2021/10/16 7:16:10
本文主要是介绍nginx启动服务提示98: Address already in use错误的解决,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Redirecting to /bin/systemctl status nginx.service ● nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2021-10-15 16:28:34 CST; 2min 0s ago Docs: http://nginx.org/en/docs/ Process: 2599 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS) Process: 4136 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=1/FAILURE) Process: 4134 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS) Oct 15 16:28:32 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Oct 15 16:28:32 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use) Oct 15 16:28:33 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Oct 15 16:28:33 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use) Oct 15 16:28:33 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Oct 15 16:28:33 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use) Oct 15 16:28:34 iZwz9d8jbsexyrvas26v6eZ nginx[4136]: nginx: [emerg] still could not bind() Oct 15 16:28:34 iZwz9d8jbsexyrvas26v6eZ systemd[1]: nginx.service: Control process exited, code=exited status=1 Oct 15 16:28:34 iZwz9d8jbsexyrvas26v6eZ systemd[1]: nginx.service: Failed with result 'exit-code'. Oct 15 16:28:34 iZwz9d8jbsexyrvas26v6eZ systemd[1]: Failed to start nginx - high performance web server.
这个异常看到就知道是端口被占用 ,具体应该是80端口被占,大部分是已经启动了Nginx占用引起的。
解决办法
首先用lsof -i :80
查看80端口被什么程序占用,返回结果如下:
nginx 4519 root 9u IPv4 235192 0t0 TCP *:http (LISTEN) nginx 4520 www 9u IPv4 235192 0t0 TCP *:http (LISTEN) nginx 4521 www 9u IPv4 235192 0t0 TCP *:http (LISTEN) nginx 4521 www 11u IPv4 238490 0t0 TCP iZwz9d8jbsexyrvas26v6eZ:http->123.150.174.180:14352 (ESTABLISHED) nginx 4521 www 12u IPv4 238368 0t0 TCP iZwz9d8jbsexyrvas26v6eZ:http->dns94.online.tj.cn:44485 (ESTABLISHED)
发现是nginx进程占用了80端口,所以我们把nginx进程kill掉,重新启动服务。
命令如下(kill 掉所有的nginx进程):
[root@xxxx sbin]# lsof -i :80 |grep nginx |grep -v grep|awk '{print $2}' 4219 4223 [root@xxx sbin]# kill -9 4219 [root@xxxx sbin]# kill -9 4223 [root@iZwz9d8jbsexyrvas26v6eZ sbin]# service nginx start Redirecting to /bin/systemctl start nginx.service
服务正常启动,服务可以正常访问
Failed to start nginx - high performance web server 异常处理
上午这个错误提示折腾了一上午也没有解决,你会看到网上各种资料说是端口占用什么的,结果我把nginx的端口改成了其它的,还是不能正常启动,试了各种办法,最后找到了原始的nginx.conf文件,然后从新配置了一下,结果一切正常了。说明很多时候是配置的原因引起的。
这篇关于nginx启动服务提示98: Address already in use错误的解决的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享
- 2024-08-14nginx 让访问带有/relid的地址返回404 ,例子 /relid-x-0.36-y-131.html-icode9专业技术文章分享
- 2024-08-14nginx 判断地址有/statics/的路径,指向到/home/html/statics/目录-icode9专业技术文章分享