Both are CentOS servers.
Server A:
After running service nginx stop
, the Nginx processes are killed.
ps -aux | grep "nginx"
root 1729 0.0 0.0 125600 6488 ? Ss Sep15 0:00 nginx: master process /usr/sbin/nginx
root 2240 0.0 0.0 125604 5744 ? S Sep15 0:00 nginx: worker process
root 2241 0.0 0.0 125604 5752 ? S Sep15 0:00 nginx: worker process
root 2242 0.0 0.0 125604 4100 ? S Sep15 0:00 nginx: worker process
root 2243 0.0 0.0 125604 5748 ? S Sep15 0:00 nginx: worker process
root 2244 0.0 0.0 125604 4100 ? S Sep15 0:00 nginx: worker process
root 2245 0.0 0.0 125604 4304 ? S Sep15 0:00 nginx: worker process
root 2246 0.0 0.0 125604 5744 ? S Sep15 0:00 nginx: worker process
root 2247 0.0 0.0 125604 5744 ? S Sep15 0:00 nginx: worker process
root 2248 0.0 0.0 125604 4044 ? S Sep15 0:01 nginx: cache manager process
root 3705 0.0 0.0 112708 988 pts/0 S+ 21:15 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx
➜ ~ service nginx stop
Redirecting to /bin/systemctl stop nginx.service
➜ ~ ps -aux | grep "nginx"
root 3896 0.0 0.0 112704 988 pts/0 S+ 21:16 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx
server B:
After running service nginx stop
, the Nginx processes are NOT killed at all:
[root@machine123 ~]# ps -aux | grep "nginx"
root 1376 0.0 0.1 136592 12592 ? Ss 09:21 0:00 nginx: master process nginx -c /etc/nginx/nginx.conf
root 1388 0.0 0.1 165788 13072 ? S 09:21 0:00 nginx: worker process
root 1389 0.0 0.1 165788 11392 ? S 09:21 0:00 nginx: worker process
root 1390 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1391 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1392 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1393 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1394 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1395 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1396 0.0 0.1 165552 9068 ? S 09:21 0:00 nginx: cache manager process
root 1892 0.0 0.0 12108 1084 pts/0 S+ 09:48 0:00 grep --color=auto nginx
[root@machine123 ~]# service nginx stop
Redirecting to /bin/systemctl stop nginx.service
[root@machine123 ~]# ps -aux | grep "nginx"
root 1376 0.0 0.1 136592 12592 ? Ss 09:21 0:00 nginx: master process nginx -c /etc/nginx/nginx.conf
root 1388 0.0 0.1 165788 13072 ? S 09:21 0:00 nginx: worker process
root 1389 0.0 0.1 165788 11392 ? S 09:21 0:00 nginx: worker process
root 1390 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1391 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1392 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1393 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1394 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1395 0.0 0.1 165788 9260 ? S 09:21 0:00 nginx: worker process
root 1396 0.0 0.1 165552 9068 ? S 09:21 0:00 nginx: cache manager process
root 1906 0.0 0.0 12108 1028 pts/0 S+ 09:49 0:00 grep --color=auto nginx
Is there anything I can do to debug this?
Thanks for any tips.
systemctl status nginx
Results:
[root@machine123 ~]# systemctl status nginx
● 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 Fri 2020-09-18 09:34:52 CST; 36min ago
Process: 1868 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 1865 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1862 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Sep 18 09:34:51 machine123 nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 18 09:34:51 machine123 nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Sep 18 09:34:51 machine123 nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 18 09:34:51 machine123 nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Sep 18 09:34:52 machine123 nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 18 09:34:52 machine123 nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Sep 18 09:34:52 machine123 nginx[1868]: nginx: [emerg] still could not bind()
Sep 18 09:34:52 machine123 systemd[1]: nginx.service: Control process exited, code=exited status=1
Sep 18 09:34:52 machine123 systemd[1]: nginx.service: Failed with result 'exit-code'.
Sep 18 09:34:52 machine123 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Somehow you've managed to start nginx outside of systemd's control. You should just kill it manually yourself, and then restart it with systemd.
Can you try:
Kill the master process: kill -9 1376 (PID of nginx master process)
Verify again: (make sure cleanly killed nginx and dont have any process using port 80, 443) ps -ef | grep nginx netstat -naopt | grep 443
Start again service nginx start