Web / NGINX Interview questions
How do you troubleshoot NGINX configuration errors before reloading?
sudo nginx -t
This command parses the full configuration tree - including all included files - and reports the exact file and line number of any syntax error, along with a final "syntax is ok / test is successful" message if everything checks out. It catches missing semicolons, unmatched braces, and unknown directives, but it doesn't catch logical mistakes like a proxy_pass pointing at the wrong port.
Only after nginx -t passes should you run systemctl reload nginx or nginx -s reload. Skipping this step is a common cause of accidental downtime, since a reload with broken configuration can leave the master process refusing to apply changes, or in worse cases affect the running workers.
More Related questions...