Software⏱️ 3 min read📅 2026-06-04

How to Fix: nginx- duplicate default server error

Duplicate server configuration for mysite.com and www.mysite.com

Quick Answer: Remove the duplicate server_name directive to resolve the error.

The 'duplicate default server' error occurs when Nginx detects multiple servers with the same configuration, including the default server, on different lines. This issue affects anyone using Nginx to serve web content and is frustrating because it can lead to unexpected behavior and errors.

Resolving this error requires attention to detail and a thorough review of your Nginx configuration files. By following these steps, you'll be able to identify and correct the duplicate server configuration, ensuring your website or application serves correctly.

🔍 Why This Happens

  • The primary reason for this error is that multiple servers are defined on different lines with the same configuration, including the default server. This can happen when a new server is added to the configuration without properly updating the existing configuration.
  • An alternative cause could be due to typos or incorrect file paths in the Nginx configuration files.

🚀 How to Resolve This Issue

Remove duplicate server definitions

  1. Step 1: Open your Nginx configuration file (usually /etc/nginx/sites-enabled/mysite.com) and locate the line with the duplicate server definition.
  2. Step 2: Identify the correct server definition by checking the 'server_name' directive. Remove any duplicate lines that have the same configuration, including the default server.
  3. Step 3: Verify that there are no other duplicate server definitions elsewhere in your Nginx configuration files.

Use a single server block

  1. Step 1: If you're using multiple domain names or subdomains, consider using a single server block with the 'server_name' directive to define all domains.
  2. Step 2: Create a new file (e.g., /etc/nginx/sites-enabled/combined.conf) and add your combined server configuration. Update your existing Nginx configuration files to point to this new file.

✨ Wrapping Up

By following these steps, you should be able to resolve the 'duplicate default server' error in Nginx. Remember to review your configuration files carefully to avoid similar issues in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions