Linux: How can I Restart Nginx WebServer?

How can I restart nginx web server on Linux?
In order restart nginx web server, you can use any of the next commands. Make sure you run this commands with root privileges:

service nginx restart


/etc/init.d/nginx restart

However, be aware that restarting Nginx webserver may interrupt all active connections. For this case, it is better to reload nginx, instead of restarting.
The following reload ngix command should work on most popular linux distributions like CentOS, RHEL, Fedora, Debian or Ubuntu:

nginx -s reload


/usr/local/nginx/sbin/nginx -s reload


/etc/init.d/nginx reload

If you are using CentOS 7, which uses systemd, you should restart nginx webserver using systemctl command by running:

systemctl restart nginx.service

As you see, you can restart and reload nginx easily from the command line from most linux systems. You should only restart nginx if you have applied changes to nginx.conf configuration file, although a simple reload should be enough too.

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *