← Back to all fixes
nginx -t fails with cryptic emerg error
The Issue
`sudo nginx -t` shows: `nginx: [emerg] unknown directive "server_namee"` or similar.
Root Cause
Syntax error in the config file — typo in a directive name, missing semicolon, unclosed bracket, or a corrupt file from copy-paste.
How to Fix
Read the exact error — it includes file path and line numberOpen the file: `sudo nano /etc/nginx/sites-available/mysite`Common errors: missing `;` at end of line, unclosed `{`, typo in directive nameValidate with: `sudo nginx -t 2>&1` — piping stderr helps see full outputStart from a minimal working config and add blocks one at a time to find the bad section