What to Do When the Service Nginx Restart Fails?

In this tutorial, you will understand how to find the error when the service Nginx restart fails.

Basically, you get the error “service nginx restart fails” when something goes wrong whereas you edit the nginx.conf. Nginx doesn’t restart after that.

1. Run the below syntax after each modification is done in your nginx config file, to resolve this error:

sudo nginx –tb

This command can assist you to search out any error in config file. The nginx errors should be fix immediately if found any.

2. Execute the below command, in case all is working well :

sudo service nginx reload

Note:

  • reload – Without restart, it means your configuration will be reloaded by nginx.
  • restart – It’ll stop and start the nginx again. Your website will go offline for few seconds.

3. The error log can be checked as below:

cat /var/log/nginx/error.log

Thus using above steps, you can resolve the “service nginx restart fails” error.