In this article, you will learn to find the error when the service Nginx restart fails.
Basically, you get the error “service nginx restart fails” when something goes wrong while you edit the nginx.conf. Nginx doesn’t restart after that.
1. To resolve this error, run the below syntax after each modification is done in your nginx config file:
sudo nginx –t
This command will help you to find any error in config file. If you find any nginx errors, fix them immediately.
2. In case all is working well, execute the below command:
sudo service nginx reload
Note:
- reload – It means your configuration will be reloaded by nginx without restart.
- restart – It will stop and start the nginx again. Your website will go offline for some seconds.
3. The error log can be checked as below:
cat /var/log/nginx/error.log
In this way, you can resolve the “service nginx restart fails” error.