Skip to content
🚀 Limited-time offer $130 for Lifetime Pro access. Buy once and use forever

Status List

Uptime & Status Pages

Contents

nginx logo

How to Test NGINX Config

Own a website, want to get alerts when it’s not working?
Consider trying out Status List for free. We have thousands of less-stressed customers who rely on us.

It’s important to test your NGINX configuration to prevent downtime. If you make a syntax error, your restart will fail and your site will go down. Fortunately it’s really easy to test your configuration before reloading.

Test Default Config

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

The NGINX command will test the default configuration files without affecting your NGINX service. You receive error information and details on which files were checked.

Config Errors

If NGINX detects an error in your configuration file, you will get output like the following:

				
					> nginx -t
nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:119
nginx: configuration file /etc/nginx/nginx.conf test failed
				
			

This error tells us there is something unexpected at /etc/nginx/nginx.conf on line 119. If we open that file we should be able to track down the issue and try again.

Common Errors

There are few things to check when you get an error:

  1. Missing braces: This is one of the most common issues. Ensure each block has an opening and closing brace. For example, ensure your server block starts with a brace and ends with one.
  2. Missing semicolon: Each of your directives (e.g. server_name) should end with a semicolon. It’s just like writing C code.
Ready to know about downtime before your customers?
 
Status List delivers uptime monitoring and professional hosted status pages for sites of all shapes and sizes.

Trusted by 1000+ companies

Testing Custom Config File

You can also test config files in non-standard locations. This can be especially helpful if you’re running Docker. Simply pass the “-c” option to your NGINX command. See below for an example:

				
					> nginx -t -c /opt/mynginx.conf
nginx: the configuration file /opt/mynginx.conf syntax is ok
nginx: configuration file /opt/mynginx.conf test is successful
				
			

You may also enjoy

Config variables are a powerful tool to control how NGINX routes requests. HTTP request, header and env variables give us precise control on request routing.
NGINX is fairly straightforward to install and provides a lot of punch right out of the box. Let's dive in and get started!
NGINX makes it easy to run Laravel on a production web server. The setup has a few steps, but it's pretty straight forward. Let's get your app into production!
The server_name config directive tells NGINX how to route client requests. server_name can match multiple domains, split out requests and work on localhost.
Learn to set up the NGINX status page with for real-time server performance monitoring and seamless integration. Let's get your status page up and running!
It's important to test your NGINX configuration to prevent downtime. Fortunately it's really easy to test your configuration before reloading.