您现在的位置:新疆网站建设-新疆网站制作-新疆二域设计>> 帮助中心>服务器相关>> Nginx服务重启失败:Job for nginx.service failed

Nginx服务重启失败:Job for nginx.service failed

作者:未知  来源:互联网  发布时间:2025-08-16 16:36:49  点击数:0

启动nginx服务提示Nginx服务重启失败,如下提示:

Job for nginx.service failed because the control process exited with error code. Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journal


问题处理:


首先用命令

命令去校验你的Nginx配置是否成功:

nginx -t

如果成功,他会给出如下信息:

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

如果你的配置文件有问题,也能从错误信息中看出来:

duplicate default server for [::]:80 in /etc/nginx/nginx.conf:41

错误已经很明显了,有多个配置文件里面使用了80端口。所以你可以用下面这条命令去查找一下:

grep -R default_server /etc/nginx

# 啰嗦一句,-R的意思是递归查找。这条命令会从 /etc/nginx下递归查找所有包含 default_server 的文件

找到该文件,写个别的端口或者删掉没用的文件,这个错误就可以解决了!

查看Nginx服务状态你可以发现:

# systemctl status nginx.service
● 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 2018-11-06 12:31:21 JST; 15s ago
...
11月 06 12:31:20 zhangch-101 nginx[1863]: nginx: [emerg] bind() to 0.0.0.0:5001 failed (98: Address already in use)
11月 06 12:31:21 zhangch-101 systemd[1]: nginx.service: control process exited, code=exited status=1
11月 06 12:31:21 zhangch-101 nginx[1863]: nginx: [emerg] still could not bind()
11月 06 12:31:21 zhangch-101 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
11月 06 12:31:21 zhangch-101 systemd[1]: Unit nginx.service entered failed state.
11月 06 12:31:21 zhangch-101 systemd[1]: nginx.service failed.


这个错误比较明显,已经有进程占用这个端口了。

这时你就应该去看看哪个进程占用了这个端口:

netstat -nap | grep 5001



关键字: nginx 重启失败

上一篇:完全卸载nginx的详细步骤
下一篇:windows2019 server如何让操作系统在指定时间自动重启?

版权所有 新疆二域信息技术有限公司 All Rights Reserved 地址:乌鲁木齐市北京南路高新街217号盈科广场B座615 备案号:新ICP备14003571号-6 新公网安备 65010402000050号