Find answers, guides, and tutorials to supercharge your content delivery.

9 Popular Nginx Commands You Should Know

Updated on October 4, 2018
9 Popular Nginx Commands You Should Know

Nginx is one of the most popular web servers in the world. So whether you’re currently using it or not, chances are, if you’re a web developer chances are you’ll likely come in contact with it at some point. Therefore there are a few important Nginx commands you should be aware of in order to get familiar with the basics of this web server.

I this guide we’re going to go over what these popular Nginx commands are, how to use them, and what each one does.

Reference the following list of popular commands if you ever need a quick reminder on how to use a certain command or what it does. Remember, if you aren’t a root user, you’ll need to sudo each command in order for them to properly work.

Start Nginx

Starting Nginx is very simple. Just use the following command:

service nginx start

If you’re using a systemd based version such as Ubuntu Linux 16.04LTS and above, use systemctl within the command, like so:

systemctl start nginx

Example response:

Starting nginx server...

Stop Nginx

Stopping Nginx will kill all system processes quickly. This will terminate Nginx even if there are open connections. In order to do so, run one of the following commands:

service nginx stop
systemctl stop nginx

Example response:

Stopping nginx Server...

This command can still, however, take some time on busy servers. Therefore, if you want Nginx to stop even faster, you can also use:

killall -9 nginx

Quit Nginx

Quitting Nginx is very similar to stopping it however it does so gracefully which means it will finish serving open connections before shutting down. To quit Nginx, use one of the following commands:

service nginx quit
systemctl quit nginx

Restart Nginx

Restarting Nginx basically performs a stop then a start. Use one of the following commands to run a Nginx restart:

service nginx restart
systemctl restart nginx

Example response:

Stopping nginx Server... [ OK ]
Starting nginx Server... [ OK ]

Reload Nginx

Reload is a bit different from restart in that, again, it is more gracefully. According to Nginx, reload is defined as “start the new worker process with a new configuration, gracefully shut down old worker processes.”. You can reload Nginx by using one of the following commands:

service nginx reload
systemctl reload nginx

Example response:

Reloading nginx Server... [ OK ]

View Server Status

Check what the current status of your Nginx web server is with one of the following commands:

service nginx status
systemctl status nginx

Example response:

nginx is running

Test Nginx Configuration

You can test your Nginx server’s configuration file before restarting or reloading it completely. This helps prevent any unforeseen errors which can cause your website to gown down. To do this there are two separate commands you can use, both return the same information:

nginx -t

Or use one of the following:

service nginx configtest
systemctl config nginx

Example response:

nginx: the configuration file /etc/nginx-sp/nginx.conf syntax is ok
nginx: configuration file /etc/nginx-sp/nginx.conf test is successful

Check Nginx Version

There are also two different ways to check your Nginx version. Both are fairly similar but one shows a little more information than the other. Use one of the following Nginx commands to print the Nginx version:

service nginx -v
systemctl -v nginx

Use the following command to print the Nginx version, compiler version and configure parameters.

service nginx -V
systemctl -V nginx

Show Command Help

If you’d like a quick reference guide of the commands available directly from within the terminal, use one of the following help commands:

service nginx -h
systemctl -h nginx


service nginx -?
systemctl -? nginx


This Nginx commands shown in this article are a few of the most popular ones. There do exist a few other parameters however these aren’t used nearly as much. Reference this guide whenever you’re stuck for a Nginx command and hopefully, you’ll find the one you need.

Supercharge your content delivery 🚀

Try KeyCDN with a free 30 day trial, no credit card required.

Get started