After installing NGINX on Ubuntu Linux, either as a web server or reverse proxy server, you'll need to learn the basics of administrating the service.

In this guide, we'll show how to check the status of NGINX on Ubuntu. This will give you information about the state of the NGINX service, to help you determine if it's running, accepting connections successfully, etc. We'll also explain the various states of NGINX, so you know what to do with the information that's presented.

In this tutorial you will learn:
  • How to check the status of NGINX with systemd
  • How to configure and access the NGINX status page
  • How to check NGINX configuration, restart, and reload the service
Checking the status of NGINX on Ubuntu
Checking the status of NGINX on Ubuntu
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux
Software NGINX
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Checking NGINX status with systemd


SUBSCRIBE TO NEWSLETTER
Subscribe to our NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


We can see whether or not NGINX is currently running by using the following systemctl command.

$ systemctl status nginx

There are a few possible results you might see when running this command. If the service is running without problems, it will say "active (running)", as seen in the screenshot below.

NGINX is active and running
NGINX is active and running

If NGINX is not running, and was last shut down gracefully, you'll see the status as "inactive (dead)".

NGINX is currently inactive
NGINX is currently inactive


If NGINX crashed, or didn't shut down gracefully, the status may say "failed" along with the reason it failed. In the screenshot below, the service crashed as a result of running the kill command, which systemd indicates to us.

NGINX status is failed, due to a received signal
NGINX status is failed, due to a received signal

In the case of a misconfigured NGINX file, the status of NGINX may indicate that it was never able to start in the first place.

NGINX indicates that it was not able to start due to a misconfigured config file
NGINX indicates that it was not able to start due to a misconfigured config file

Checking NGINX status with status page



Setting up the NGINX status page can give you bunch of information about active connections and other server statistics.

Edit your NGINX site configuration file and add the following block of code within the server directive.

location /nginx_status {
                stub_status on;
                allow 127.0.0.1;
                deny all;
        }
Setting up the NGINX status page
Setting up the NGINX status page

This will allow localhost (127.0.0.1) to access the page example.com/nginx_status to see the NGINX status page.

The output looks like this, but will have different numbers depending on the number of connections your server has.

Active connections: 16
server accepts handled requests
 417 417 610 
Reading: 0 Writing: 3 Waiting: 5

Here's a breakdown of how to interpret the data:

  • Active connections: Total number of open and active connections to NGINX
  • The three numbers on line three:
    1. Number of accepted connections
    2. Number of handled connections (usually the same as accepted connections)
    3. Total number of client requests
  • Reading: Number of current connections in which NGINX is reading the request header
  • Writing: Number of current connections in which NGINX is writing a response to the client
  • Waiting:: Number of open connections that are idle and waiting for a requests

SUBSCRIBE TO NEWSLETTER
Subscribe to our NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Accessing the NGINX status page
Accessing the NGINX status page

Check NGINX configuration, restart and reload NGINX

Now that you know how to check the status of NGINX, knowing how to check your configuration for errors also goes hand in hand, along with restarting and reloading NGINX.

Use the following command to check your NGINX configuration files.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

And check out our guide on how to restart or reload NGINX. for an explanation about the differences.

$ sudo systemctl restart nginx
AND
$ sudo systemctl reload nginx

Closing Thoughts

In this guide, we saw how to check the status of NGINX on Ubuntu Linux. This included checking the service using systemctl, as well as setting up and checking the NGINX status page. We also learned how to check our NGINX configuration for errors, and restart or reload the service. All of this information is essential for web admins, and should help you to keep tabs on the state of your website or reverse proxy server.

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.