栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

nginx启动失败nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx启动失败nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)

./nginx 启动nginx,在启动时报错端口被占用

[root@localhost sbin]# ./nginx
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:7001 failed (98: Address already in use)

lsof -i:7001,查看被占用的进程

[root@localhost sbin]# lsof -i:7001
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    104324 root 1514u  IPv6 822256      0t0  TCP localhost.localdomain:afs3-callback (LISTEN)
java    104324 root 1515u  IPv6 811847      0t0  TCP localhost:afs3-callback (LISTEN)
java    104324 root 1516u  IPv6 810961      0t0  TCP localhost:afs3-callback (LISTEN)
java    104324 root 1517u  IPv6 810962      0t0  TCP localhost.localdomain:afs3-callback (LISTEN)
java    104324 root 1518u  IPv6 822257      0t0  TCP localhost.localdomain:afs3-callback (LISTEN)

解决办法:

方法一:如果涉及的进程不需要则将它杀死,杀死后./nginx重新启动nginx,80端口同理

[root@localhost nginx]# kill -9 7001

[root@localhost sbin]# ./nginx

方法二:涉及进程需要,则修改端口

进入sbin目录下修改nginx.conf文件

修改前:

server {
        listen      7001;
        server_name  localhost;

修改后:

将listen端口改为其他端口

server {
        listen      17001;
        server_name  localhost;

 ./nginx 重新启动nginx

[root@localhost sbin]# ./nginx

ps -ef | grep nginx查看进程:已启动

[root@localhost sbin]# ps -ef | grep nginx
root     106562      1  0 23:19 ?        00:00:00 nginx: master process ./nginx
nobody   106563 106562  0 23:19 ?        00:00:00 nginx: worker process
nobody   106564 106562  0 23:19 ?        00:00:00 nginx: worker process
root     106568 106205  0 23:19 pts/0    00:00:00 grep --color=auto nginx

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/848358.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号