---
title: "Steering NGINX Test Config Before Screwing it Up"
description: "In NGINX test config before you deploy them by learning these tricks of the trade in this step-by-step tutorial."
canonical: "https://adamtheautomator.com/nginx-test-config/"
---

# Steering NGINX Test Config Before Screwing it Up

> In NGINX test config before you deploy them by learning these tricks of the trade in this step-by-step tutorial.

Source: https://adamtheautomator.com/nginx-test-config/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Steering NGINX Test Config Before Screwing it Up](https://adamtheautomator.com/wp-content/uploads/2021/11/How-to-Test-Your-NGINX-Configuration-Before-Screwing-it-Up.jpg)

# Steering NGINX Test Config Before Screwing it Up

[![](https://secure.gravatar.com/avatar/fc510e274a5e6eb1099f60b136d4cc804e9387b63960e935b69dd5af62c117ba?s=192&d=mm&r=g)Ravgeet Dhillon](https://adamtheautomator.com/author/ravgeet-dhillon/)17 November 20211 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[NGINX](/tag/nginx/)

Table of Contents

*   [Validating NGINX Configuration File Syntax](#validating-nginx-configuration-file-syntax)
*   [Conclusion](#conclusion)

We’ve all been there; you need to make “just this one little change” to your NGINX configuration and before you know it, your web server is down. Fortunately, there’s an answer in NGINX test config changes!

There are several tasks you can perform to test config changes in NGINX with built-in switches, troubleshooting best practices, and testing permissions. In this tutorial, you’re going to learn how to get started ensuring you never take production down again!

## Validating NGINX Configuration File Syntax

NGINX configuration files follow a specific schema. You can’t just provide any text in a configuration file and expect NGINX to understand it. You need to test it’s syntax first before releasing it into an important environment.

To test an NGINX config file, the `nginx` binary provides the `-t` switch. The `-t` switch is a flag that tells NGINX to read the config file (and all files referenced in the main config file) and ensure the syntax is valid.

```bash
sudo nginx -t
```

> _The `-t` switch not only tests syntax in the main NGINX test config file, but it also reads and tests syntax for all files referenced via an `include` statement also._

If the syntax of the configuration file is valid, you’ll see the following:

![NGINX Configuration Test is Successful](https://adamtheautomator.com/wp-content/uploads/2021/11/image-233.png)

NGINX Configuration Test is Successful

On the contrary, you’ll see below that if you’ve made a mistake in the config file, the `-t` switch will tell you.

![NGINX Configuration Error](https://adamtheautomator.com/wp-content/uploads/2021/11/image-234.png)

NGINX Configuration Error

If, for example, NGINX can’t read an [included](http://nginx.org/en/docs/ngx_core_module.html#include) file in the config file due to a permission problem, you’ll see the below output.

![Permissions Error in the Included file.](https://adamtheautomator.com/wp-content/uploads/2021/11/image-235.png)

Permissions Error in the Included file.

## Conclusion

You should now know how to use do NGINX test config file syntax! When you make a change to an NGINX config file, remember to always run the `-t` switch! And if you’re using a [MAC](https://adamtheautomator.com/nginx-mac/), here’s how to set up NGINX.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fnginx-test-config%2F&text=Steering%20NGINX%20Test%20Config%20Before%20Screwing%20it%20Up)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fnginx-test-config%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fnginx-test-config%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/11/How-to-Install-Statping-on-Ubuntu-Linux.jpg)

### [How to Install Statping on Ubuntu Linux](/statping/)

Make sure your services are up and running with this open source web and app status monitoring solution in Statping!

![](https://adamtheautomator.com/wp-content/uploads/2022/09/How-to-Fix-NGINX-502-Errors-Now.jpg)

### [How to Fix NGINX 502 Errors Now!](/nginx-502/)

NGINX 502 errors are a challenge for any system administrator, learn how to solve these pesky errors in this ATA Learning tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2022/05/Simple-Virtual-Host-Management-With-NGINX-Proxy-Manager.jpg)

### [Simple Virtual Host Management With NGINX Proxy Manager](/nginx-proxy-manager/)

Learn to manage virtual hosts and SSL certificates quickly and easily with the NGINX Proxy Manager in this step-by-step tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
