nginx: [emerg] bind() to 0.0.0.0:4433 failed (98: Address already in use)

  • Post author:
  • Post category:其他


提示:查询Nginx进程:ps -aux | grep nginx。



一、使用sudo systemctl restart nginx 重启Nginx服务出现以下错误:

[root@Zcgl_Web1_Dev nginx]# sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.


使用 systemctl status nginx -l 查询时,看到错误:

nginx: [emerg] bind() to 0.0.0.0:4433 failed (98: Address already in use)




二、解决办法:

sudo pkill -f nginx & wait $!
sudo systemctl start nginx



[root@Zcgl_Web1_Dev conf.d]# sudo pkill -f nginx & wait $!
[2] 1038336
[2]-  Done                    sudo pkill -f nginx
[root@Zcgl_Web1_Dev conf.d]# ps -aux | grep nginx
root     1038342  0.0  0.0  12136  1148 pts/2    S+   14:51   0:00 grep --color=auto nginx
[root@Zcgl_Web1_Dev conf.d]# sudo systemctl start nginx
[root@Zcgl_Web1_Dev conf.d]# ps -aux | grep nginx
root     1038353  0.0  0.0 121436  2360 ?        Ss   14:51   0:00 nginx: master process /usr/sbin/nginx
root     1038354  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038355  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038356  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038357  0.0  0.0 152040  8200 ?        S    14:51   0:00 nginx: worker process
root     1038358  0.0  0.0 152040  8204 ?        S    14:51   0:00 nginx: worker process
root     1038359  0.0  0.0 152040  8204 ?        S    14:51   0:00 nginx: worker process
root     1038360  0.0  0.0 152040  8188 ?        S    14:51   0:00 nginx: worker process
root     1038361  0.0  0.0 152040  8180 ?        S    14:51   0:00 nginx: worker process
root     1038364  0.0  0.0  12136  1132 pts/2    S+   14:51   0:00 grep --color=auto nginx



三、Nginx常用命令

1、想要查看主机运行的Nginx版本,可以使用如下命令

# nginx -v
# nginx -V


2、检查Nginx配置是否有错

# nginx -t
#如果不仅想查看配置文件是否正确,还想知道Nginx都使用了哪些配置文件,只需要使用”-T”参数即可:
# nginx -T

3、

启动Nginx服务

# systemctl start nginx #systemd
OR
# service nginx start   #sysvinit
OR
# start nginx #打开 nginx


4、设置Nginx服务开机自启动

# systemctl enable nginx #systemd
OR
# service nginx enable   #sysvinit


5、重新启动Nginx

# systemctl restart nginx #systemd
OR
# service nginx restart   #sysvinit
OR
# nginx -s reopen #重启Nginx
OR
# nginx -c filename #设置配置文件(默认是:/etc/nginx/nginx.conf),
#例如sudo nginx -c /etc/nginx/nginx.conf 或 
sudo nginx -t -c /etc/nginx/nginx.conf(-t可以检查验证nginx配置文件是否正确) 或 
 /usr/sbin/nginx -t -c /etc/nginx/nginx.conf


6、查看Nginx运行状态

# systemctl status nginx #systemd
OR
# service nginx status   #sysvinit


7、重新载入配置文件

# systemctl reload nginx #systemd
OR
# service nginx reload   #sysvinit
OR
# sudo nginx -s reload #重新加载Nginx配置文件,然后以优雅的方式重启Nginx


8、停止Nginx服务

# systemctl stop nginx #systemd
OR
# service nginx stop   #sysvinit
OR
# nginx -s stop #强制停止Nginx服务
OR
# nginx -s quit #优雅地停止Nginx服务(即处理完所有请求后再停止服务)


9、查看Nginx的帮助文件

# nginx -h



版权声明:本文为kuangpengfei原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。