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
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.
> 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.
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.
There are few things to check when you get an error:
Trusted by 1000+ companies
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
© Status List 2024