Nginx: nginx: [emerg] unknown directive "x" in /etc/nginx/sites-enabled/x:12 — configuration file test failed
Nginx found a directive it doesn’t know — a typo, a missing semicolon on the previous line, a directive from a module that isn’t installed, or Apache syntax in an Nginx file.
nginx: [emerg] unknown directiveconfiguration file /etc/nginx/nginx.conf test failed[emerg] unexpected "}"[emerg] invalid number of arguments Meaning
Always run nginx -t before reload. Missing ; makes the next word look like a directive. Directives like more_set_headers, brotli, geoip2 need dynamic modules loaded.
Common causes
- Typo or missing semicolon on the previous line
- Module not installed/loaded (headers-more, brotli, geoip2)
- Apache/.htaccess syntax pasted into Nginx
- Hidden characters (BOM, smart quotes)
⚡ Quick fix
- Run sudo nginx -t and check the reported line and the one before
- Install/load the module (load_module)
- Translate Apache rules to Nginx equivalents
Detailed fix by platform
Shell
- nginx
sudo nginx -t sudo nginx -V 2>&1 | tr ' ' ' ' | grep module
How to diagnose
- Line — Reported line and the previous one
- Modules — nginx -V
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Nginx / Apache
- WebSocket connection failed through Nginx (missing Upgrade headers) Browser: WebSocket connection to 'wss://example.com/socket' failed: Error during WebSocket handshake: Unexpected response code: 400 (nginx proxy)
- AH00124: Request exceeded the limit of 10 internal redirects Apache: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary
- AH00898: Error reading from remote server (502 Proxy Error) Apache: [proxy_http:error] AH01102: error reading status line from remote server 127.0.0.1:3000 / AH00898: Error reading from remote server returned by /api
Other ways to find it
Where this error sits
Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026