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的詳細步驟
下一篇:windows2019 server如何讓操作系統在指定時間自動重啟?
相關內容: