Sometimes after Nginx service restart and you’re trying to get the service status, you might get the following status code line:
Process: 10316 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
What does it mean?! Well, the start-stop-daemon it’s trying to stop the nginx gracefully, and if it timeouts, permission related issues being the most common reason, it will return status code 2
. The solution though, it’s pretty simple.
Prerequisites
- Linux bash environment
- sudo privileges
- Nginx
Solution
Step 1. Instead of restarting the service, try to stop it first.
sudo systemctl stop nginx
Step 2. Start it again.
sudo systemctl start nginx
Step 3. Confirm the Nginx status code 0
.
sudo systemctl status nginx
Expected output:
Process: 10316 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
That’s it!
Conclusion
Although it’s not an issue, getting rid of status=2
red marks in the nginx status code, it’s totally understandable from a junior sysadmin standpoint. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.