Don't Restart Nginx
Learn why restarting Nginx can be detrimental to your site, an alternative to restarting Nginx, and times where restarting is unavoidable.
Table of Contents 📖
Restart Nginx
Reloading Nginx is safer than restarting it. This is because when restarting Nginx, the Nginx server is shut down, including all related services, before being turned on again. Also, if Nginx is restarted with a configuration file that has syntax errors, it will not start at all. As a result, Nginx should only really be restarted when making significant configuration updates. If you need to restart Nginx, first check the validity of the configuration file using the following command:
INFO: Examples of major configuration updates are port and IP address changes.
nginx -t
Reload Nginx
Unlike restarting Nginx, reloading it keeps the Nginx server running while it reloads the updated configuration file. This means that Nginx will not close down current connections when reloading. Also, if there are any syntax errors in the configuration file, the reload is aborted and the server keeps running based on the old configuration files. To reload Nginx, we need to send the reload signal to the master process using the following command.
nginx -s reload
INFO: The reload command reloads the configuration file using the SIGHUP signal.