nginx: [emerg] unknown directive Nginx / Apache Origin: Edge & web server OSI layer 7 · Application Last updated 13 Oct 2026

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.

Exact message you may see nginx: [emerg] unknown directiveconfiguration file /etc/nginx/nginx.conf test failed[emerg] unexpected "}"[emerg] invalid number of arguments
Seen on: Nginx

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

  1. Run sudo nginx -t and check the reported line and the one before
  2. Install/load the module (load_module)
  3. Translate Apache rules to Nginx equivalents

Detailed fix by platform

Shell

  1. nginx
    sudo nginx -t
    sudo nginx -V 2>&1 | tr ' ' '
    ' | grep module

How to diagnose

  1. Line — Reported line and the previous one
  2. 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:

Where this error sits

Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):

1000 — Cloudflare Error 1000: DNS points to prohibited IP (Cloudflare)10001001 — Cloudflare Error 1001: DNS resolution error (Cloudflare)10011002 — Cloudflare Error 1002: DNS points to Prohibited IP / Restricted (Cloudflare)10021004 — Cloudflare Error 1004: Host Not Configured to Serve Web Traffic (Cloudflare)10041018 — Cloudflare Error 1018: Could not find host (Cloudflare)10181034 — Cloudflare Error 1034: Edge IP Restricted (Cloudflare)10341049 — MySQL ERROR 1049 (42000): Unknown database 'x' (MySQL)10493D000 — FATAL: database "x" does not exist (PostgreSQL)3D000nginx: [e…

Explore the map of this error Full error map →

🧠 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.