Unable to restart nginx via systemd because it's already running
sudo killall apache2
To solve Job for nginx.service
failed because the control process exited with error code. See systemctl status nginx.service
and journalctl -xe
for details.
Related videos on Youtube
SoothingMist
Updated on September 18, 2022Comments
-
SoothingMist over 1 year
I'm trying to restart nginx, and systemd doesn't want to.
As far as I can tell, nginx is humming along just fine, and it's answering requests as expected, but systemd doesn't appear to think it's in control of the service, so I guess it tries to start a new copy, which fails because now it tries to bind to :80 which is already taken.
After some troubleshooting, I just gave up and rebooted the machine, figuring that would resolve the issue, but to my surprise that lands me back in the same state again.
The only way I can find to make systemd happy is
# killall nginx # systemctl restart nginx.service
But I obviously don't want to rely on that. Info about my current state:
# systemctl restart nginx.service Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. # journalctl -xe -- Unit nginx.service has begun starting up. Oct 22 12:12:43 shared1 nginx[4772]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx[4772]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx[4772]: nginx: [emerg] still could not bind() systemd[1]: nginx.service: Control process exited, code=exited status=1 systemd[1]: Failed to start A high performance web server and a reverse proxy server. -- Subject: Unit nginx.service has failed # netstat -lpn | grep :80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3607/nginx # ps fax | grep nginx 4827 pts/0 S+ 0:00 \_ grep --color=auto nginx 3607 ? Ss 0:00 nginx: master process /usr/sbin/nginx 3608 ? S 0:00 \_ nginx: worker process 3609 ? S 0:00 \_ nginx: cache manager process # cat /etc/issue Ubuntu 16.04.3 LTS \n \l $ nginx -v nginx version: nginx/1.10.3 (Ubuntu) $ find /etc/systemd/ /lib/systemd/system -name nginx.service /etc/systemd/system/multi-user.target.wants/nginx.service /lib/systemd/system/nginx.service $ stat /etc/systemd/system/multi-user.target.wants/nginx.service 2>&1 | head -n1 File: '/etc/systemd/system/multi-user.target.wants/nginx.service' -> '/lib/systemd/system/nginx.service' $ stat /lib/systemd/system/nginx.service 2>&1 | head -n2 File: '/lib/systemd/system/nginx.service' Size: 986 Blocks: 8 IO Block: 4096 regular file
-
jpezz over 6 yearsCan you stop it with "systemctl stop nginx.service".
-
SoothingMist over 6 years@jpezz Only in the sense that systemd doesn't complain about it, but the running process doesn't actually terminate if I try.
-
jpezz over 6 yearsYou need to find out if systemd is starting it in the first place. Is nginx.service in /etc/systemd or its subdirectories? Is it in lib/systemd/system ? What versions of Ubuntu & nginx?
-
SoothingMist over 6 years@jpezz I think I have added the relevant information to the question. :)
-
Newskooler almost 5 yearsI have the same issue. Still no solution :/
-
-
WinEunuuchs2Unix almost 4 yearsCan't argue with killing the process.