nginx: duplicate location Nginx / Apache Origin: Edge & web server OSI layer 7 · Application Last updated 5 Nov 2026

Nginx: nginx: [emerg] duplicate location "/" in /etc/nginx/sites-enabled/default:52

Two location blocks with the same match exist in one server block (often from two included files).

Exact message you may see nginx: [emerg] duplicate location "/" in /etc/nginx/sites-enabled/default[emerg] duplicate locationduplicate location "/" in[emerg] duplicate "default_server" for "0.0.0.0:80"[emerg] a duplicate default server for 0.0.0.0:80
Seen on: Nginx Linux

Meaning

Each exact location may appear once per server. The default site and your own file both define location /, or an included snippet repeats one. Remove/merge duplicates, or disable the default site (rm /etc/nginx/sites-enabled/default).

Common causes

  • Same location defined twice
  • Default site and custom site both enabled for the same server_name
  • Included snippets duplicate locations
  • Copy-paste of config
  • Regex location repeated

⚡ Quick fix

  1. Remove or merge the duplicate location
  2. Disable unneeded default site
  3. Use nginx -T | grep -n "location /" to find duplicates

Detailed fix by platform

Linux

  1. sudo nginx -T 2>/dev/null | grep -n 'location /'

How to diagnose

  1. Location — Which pattern?
  2. Files — Which include?
  3. Default — Enabled?

🔧 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):

could not build the server_names_hash, you should increase server_names_hash_bucket_size — Nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64 (Nginx / Apache)could not build the s…nginx: [emerg] open() failed (2: No such file or directory) — Nginx: nginx: [emerg] open() "/etc/nginx/snippets/fastcgi-php.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/app:20 (Nginx / Apache)nginx: [emerg] open()…nginx: [emerg] unexpected end of file, expecting ";" or "}" — Nginx: nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/conf.d/site.conf:42 (Nginx / Apache)nginx: [emerg] unexpe…nginx: conflicting server name ignored — Nginx: nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored (Nginx / Apache)nginx: conflicting se…nginx: directive is not terminated by ";" — Nginx: nginx: [emerg] directive "proxy_pass" is not terminated by ";" in /etc/nginx/sites-enabled/app:15 (Nginx / Apache)nginx: directive is n…no "ssl_certificate" is defined for the "listen ... ssl" directive — Nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/default:3 (SSL / TLS)no "ssl_certificate" …Welcome to nginx! shown instead of my site — Browser: Welcome to nginx! If you see this page, the nginx web server is successfully installed and working (Nginx / Apache)Welcome to nginx! sho…nginx: du…

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.