Back to blog
Linux & Servers Published September 25, 2026•Updated November 10, 2026

Nginx "conflicting server name ... ignored": How to Fix

Automate WhatsApp Alerts
Start Free ➔

When testing Nginx configuration files with nginx -t or reloading the service, you may encounter one of the following emergency warnings:

nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored

or:

nginx: [warn] conflicting server name "api.example.com" on [::]:443, ignored

Quick fix: two server {} blocks use the same server_name on the same listen address, and Nginx ignores the second one, so your changes to it never take effect. Find every place the name is declared, across all included files:

sudo nginx -T 2>/dev/null | grep -nE '^# configuration file|server_name[^;]*example\.com'

The # configuration file lines show which file each match comes from. Usually it's a backup copy left in sites-enabled/, the same site enabled twice, or a second HTTPS block added by Certbot. Remove the duplicate, then sudo nginx -t && sudo systemctl reload nginx.

While Nginx will continue running, this warning indicates a critical architectural defect: multiple virtual server blocks have claimed the exact same hostname on the same socket listener (IP:port).

Because Nginx can bind only one server block to an incoming (socket, Host) combination, it silently ignores all subsequent duplicate declarations. In production, this results in traffic routing to stale codebases, incorrect TLS certificates being served to clients, and updates in newly created virtual hosts failing to take effect.

In this guide, we examine Nginx's virtual-host resolution hierarchy, analyze multi-file include traps, and provide deterministic CLI diagnostics and production templates to eliminate duplicate socket conflicts permanently.


[!TIP] Proactive SSL & Host Header Audits When virtual hosts collide, Nginx frequently serves the default SSL certificate instead of the domain-specific certificate. Verify your active TLS certificates and Host header routing instantly with our free SSL Inspector, HTTP Header Checker, and DNS Lookup Tool.


The Core Problem: How Nginx Binds Sockets to Hostnames

Nginx does not enforce global uniqueness for server_name across your entire configuration. It enforces uniqueness per listening socket tuple (IP, Port, AddressFamily):

                         Incoming TCP Handshake
                                   │
                                   ▼
                   ┌───────────────────────────────┐
                   │  Destination Socket Listener  │
                   │   (e.g., 0.0.0.0:443 / IPv4)  │
                   └───────────────┬───────────────┘
                                   │
                                   ▼
                   ┌───────────────────────────────┐
                   │     TLS SNI & Host Header     │
                   │      "api.example.com"        │
                   └───────────────┬───────────────┘
                                   │
        ┌──────────────────────────┴──────────────────────────┐
        │                                                     │
        ▼                                                     ▼
┌───────────────────────────────┐             ┌───────────────────────────────┐
│ Server Block A (Loaded First) │             │ Server Block B (Loaded Later) │
│ server_name api.example.com;  │             │ server_name api.example.com;  │
│ proxy_pass http://backend-v2; │             │ proxy_pass http://backend-v1; │
└───────────────┬───────────────┘             └───────────────┬───────────────┘
                │                                             │
         [ ACTIVE OWNER ]                             [ SILENTLY IGNORED ]

Why "Ignored" Causes Silent Outages

When Nginx builds its runtime hash tables:

  1. The first server {} block encountered during configuration parsing wins ownership of the (socket, hostname) tuple.
  2. Every subsequent server {} block claiming the same hostname on that socket is discarded from the lookup table.
  3. Requests for that domain will execute the directives of Block A, while Block B remains completely dead configuration.

This explains the classic sysadmin dilemma: "I updated /etc/nginx/sites-available/api.conf, ran nginx -s reload, but Nginx is still serving the old website."


Nginx Hostname Resolution Order & Precedence

When a request reaches a listening socket, Nginx selects the target server {} block using strict precedence rules:

Exact name → longest leading wildcard (*.example.com) → longest trailing wildcard (mail.*) → first matching regex → default server.

Complete Matching Precedence Matrix

PrecedenceMatch TypeSyntax ExampleInternal MechanismConflict & Collision Behavior
1 (Highest)Exact Nameserver_name api.example.com;Exact Hash Lookup TableMultiple exact names on the same socket trigger [warn] conflicting server name, ignored.
2Longest Leading Wildcardserver_name *.example.com;Leading Wildcard Hash TableLongest prefix wins (e.g., *.api.example.com takes precedence over *.example.com).
3Longest Trailing Wildcardserver_name mail.*;Trailing Wildcard Hash TableLongest suffix wins.
4First Matching Regexserver_name ~^(.+)\.example\.com$;Sequential Regex EvaluationConfiguration order matters. First matching regex is selected; specificity does not apply.
5 (Fallback)Default Serverlisten 80 default_server;Direct Socket FallbackCatches all requests with unrecognized or missing Host headers.

4 Common Multi-File Collision Traps

In real-world production fleets, conflicting server names rarely happen in a single file. They come from include paths and automation tools.

1. Debian/Ubuntu sites-available vs sites-enabled

On Ubuntu/Debian, Nginx configurations live in /etc/nginx/sites-available/ and are symlinked into /etc/nginx/sites-enabled/.

A disastrous misconfiguration occurs when nginx.conf contains:

# BUG: Parsing both directories causes every site to be parsed twice!
include /etc/nginx/sites-available/*;
include /etc/nginx/sites-enabled/*;

Fix: Only include sites-enabled/*.

include /etc/nginx/sites-enabled/*;

2. Backup Copies That Still Match the Include Pattern

Whether a backup copy is loaded depends on the include pattern:

  • Debian/Ubuntu include /etc/nginx/sites-enabled/*; loads every file in that folder, whatever its name. A copy like sites-enabled/example.com.bak or example.com.old is parsed as a second site.
  • include /etc/nginx/conf.d/*.conf; only loads names ending in .conf. app.conf.bak is ignored, but app-old.conf or app.backup.conf is loaded.
ls -la /etc/nginx/sites-enabled/ /etc/nginx/conf.d/

Fix: keep backups outside /etc/nginx/ (for example in /root/nginx-backups/), and keep only symlinks to real sites in sites-enabled/.

3. Certbot Let's Encrypt Automated Injections

When Certbot runs (certbot --nginx), it inspects your existing HTTP server {} block and automatically generates a companion HTTPS server {} block.

If a developer later creates an HTTPS block manually or re-runs Certbot against a different virtual host template, duplicate HTTPS blocks with identical server_name example.com; entries are created across separate files.

4. IPv4 vs. IPv6 Dual-Stack Mismatches

A server block defined on IPv4:

server {
    listen 80;
    server_name example.com;
}

does not conflict with a server block defined on IPv6:

server {
    listen [::]:80;
    server_name example.com;
}

However, if you declare listen 80; in two different files for example.com, Nginx triggers the warning specifically for 0.0.0.0:80.


Step-by-Step Diagnostic Sequence

Follow this CLI diagnostic workflow to isolate and remove duplicate virtual host declarations across your fleet.

Step 1: Dump the Effective Runtime Configuration

Do not manually inspect individual .conf files. Dump the entire expanded configuration stream:

sudo nginx -T | grep -nE 'server_name|listen'

Example diagnostic trace:

42:        listen 80 default_server;
43:        server_name _;
87:        listen 443 ssl;
88:        server_name api.example.com;   <-- Block 1 (Active)
142:       listen 443 ssl;
143:       server_name api.example.com;   <-- Block 2 (Ignored Conflict!)

Step 2: Locate the Physical File Paths

Search the filesystem for every file containing the offending domain:

sudo grep -rn "api.example.com" /etc/nginx/

Output:

/etc/nginx/sites-enabled/api.conf:4:    server_name api.example.com;
/etc/nginx/conf.d/api-legacy.conf:8:    server_name api.example.com;

This immediately reveals that api-legacy.conf is competing with api.conf.

Step 3: Inspect Active Listening Sockets

Verify the exact IP and port bindings of Nginx worker processes:

sudo ss -tulpn | grep nginx

Expected output:

tcp   LISTEN 0 511 0.0.0.0:80    0.0.0.0:* users:(("nginx",pid=1200,fd=6))
tcp   LISTEN 0 511 0.0.0.0:443   0.0.0.0:* users:(("nginx",pid=1200,fd=7))
tcp6  LISTEN 0 511 [::]:80       [::]:*    users:(("nginx",pid=1200,fd=8))
tcp6  LISTEN 0 511 [::]:443      [::]:*    users:(("nginx",pid=1200,fd=9))

Step 4: Test TLS / SNI Routing Independently

Bypass public DNS and verify which certificate and upstream Nginx returns for the domain:

# Verify TLS Certificate presented for SNI
openssl s_client -servername api.example.com -connect 127.0.0.1:443 </dev/null 2>/dev/null | \
  openssl x509 -noout -subject -issuer -dates

# Verify HTTP routing payload
curl -vk --resolve api.example.com:443:127.0.0.1 https://api.example.com/

Production-Grade Multi-Domain Configuration Template

Below is the recommended production architecture separating explicit default catch-alls from domain-specific routing.

1. Default Catch-All Server (/etc/nginx/conf.d/00-default.conf)

Explicitly reject unmapped domains, random IP scans, and malicious Host headers:

# Drop unmatched HTTP requests cleanly
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _;
    return 444; # Nginx-specific: Close connection with zero payload
}

# Drop unmatched HTTPS requests at TLS handshake
server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    server_name _;
    ssl_reject_handshake on; # Available in modern Nginx versions
}

2. Dedicated Domain Virtual Host (/etc/nginx/sites-available/api.example.com.conf)

# 1. Canonical HTTP -> HTTPS Redirection
server {
    listen 80;
    listen [::]:80;

    server_name api.example.com;
    return 301 https://$host$request_uri;
}

# 2. Production HTTPS Virtual Host
server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name api.example.com;

    # SSL Certificates
    ssl_certificate     /etc/letsencrypt/live/api.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;

    # Reverse Proxy Target
    location / {
        proxy_pass http://127.0.0.1:8000;

        proxy_http_version 1.1;
        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Applying and Verifying Configuration

After deleting or consolidating duplicate server blocks:

# 1. Verify syntax and ensure 0 warnings
sudo nginx -t

# 2. Reload Nginx gracefully without dropping connections
sudo systemctl reload nginx

# 3. Check systemd journal to confirm clean reload with zero warnings
sudo journalctl -u nginx --since "1 minute ago"

Expected output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Comprehensive Troubleshooting Checklist

Action ItemDiagnostic CommandExpected Resolution
Audit Includessudo nginx -T | grep includeVerify sites-available is not included alongside sites-enabled.
Identify Duplicatessudo grep -rn "server_name" /etc/nginx/Locate multiple files declaring identical domains on identical ports.
Check Symlinksls -la /etc/nginx/sites-enabled/Remove orphaned or duplicate broken symlinks.
Test Host Routingcurl -Iv -H "Host: domain.com" http://127.0.0.1/Verify expected virtual host handles the request.
Test SSL Certificatesopenssl s_client -servername domain.com -connect 127.0.0.1:443Ensure SNI negotiation delivers the domain-specific certificate.

Check that each domain serves what you expect

This warning is easy to miss because Nginx keeps running: the ignored block just never takes effect, and a domain keeps serving the old site or the wrong certificate.

An HTTP monitor per domain with a keyword check (a word that only appears on the correct site) fails when the wrong server block answers, and SSL expiry tracking (paid plans) shows which certificate each domain actually serves. With Pingzo, checks run every 1 to 15 minutes depending on your plan, an incident opens when 3 of the last 5 checks fail, and alerts go to WhatsApp, Slack, Telegram, Discord or email.

Zero-Code Uptime Alerts

Stop Finding Out About Outages from Angry Users

Get instant WhatsApp & Discord alerts the second your API, website, or server goes down. Setup in 30 seconds, with checks as often as every minute.

WhatsApp & Discord 60-Second Checks Free Forever Plan
Try Pingzo Free

Know before your users do

Connect official WhatsApp notification channels, Discord webhooks, Telegram bots, and public status pages. Start in 30 seconds.

Create Free Monitor