Ultimate Guide to Fixing Nginx [warn] conflicting server name Warning
Content
In daily web server maintenance and deployment, it is a good practice to run `nginx -t` to check syntax after modifying Nginx configurations. However, you might occasionally encounter a `conflicting server name` warning. Although Nginx states that the `syntax is ok`, this warning indicates a logical flaw in your configuration that could prevent your website from routing as expected.
This article details the root cause of this warning and provides a complete guide to troubleshooting and fixing it.
## 1. Error Reproduction
When configuring an HTTPS site, you might see the following output during a configuration test:
```bash
[root@VM-centos ~]# docker exec ee-nginx-1.23.3 nginx -t
nginx: [warn] conflicting server name "ai.lib00.com" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
---
## 2. Root Cause Analysis
The core reason for this warning is: **The same domain name (`server_name`) is defined multiple times on the same port (e.g., `443` or `80`) within the Nginx configuration files.**
* **Conflict Mechanism**: While parsing the configuration, Nginx finds multiple `server` blocks declaring the exact same `server_name` (e.g., `ai.lib00.com`) and listening port (`443`).
* **How Nginx Handles It**: Nginx adopts a "first-come, first-served" strategy. It loads the first configuration it reads and **ignores** any subsequent duplicate configurations. This is why the test still shows `syntax is ok`, but in reality, your latest configuration changes might not take effect at all.
---
## 3. Quick Troubleshooting Steps
To resolve this issue, we need to locate all configuration files that define the conflicting domain. DP@lib00 recommends the following steps for precise identification:
### Step 1: Global Domain Search
Navigate to the Nginx configuration directory (usually `/etc/nginx` or `/usr/local/nginx/conf`) and use the `grep` command to search for the conflicting domain globally:
```bash
grep -r "ai.lib00.com" /etc/nginx/
```
### Step 2: Identify Common Conflict Scenarios
Based on the `grep` output, you will typically find one of the following situations:
1. **Leftover Expired Files (Most Common)**: Historical configuration files (e.g., `old_site.conf`) in the `conf.d/` directory were not deleted.
2. **Backup Files Accidentally Loaded**: It's common to run `cp site.conf site.conf.bak` before making changes. If the main Nginx config uses `include /etc/nginx/conf.d/*;`, the `.bak` file will also be loaded.
3. **Duplicates within a Single File**: Accidentally copy-pasting two identical `server { ... }` blocks within the same configuration file.
4. **Duplicate Symlinks**: When using the `sites-available` and `sites-enabled` pattern, multiple symlinks might point to the same site configuration.
---
## 4. Real-World Scenario and Fix
In a real-world scenario from wiki.lib00.com, a developer investigated the issue and discovered that an expired config file containing the same domain `ai.lib00.com` was left in the `conf.d/` directory.
**How to Fix**:
Once you locate the duplicate definitions, simply delete the redundant `server` blocks or the expired configuration files.
```bash
# Delete the expired configuration file
rm -f /etc/nginx/conf.d/expired_site.conf
# Retest Nginx configuration
nginx -t
# Reload Nginx once the warning is gone
nginx -s reload
```
---
## 5. Best Practices for Nginx Configuration Management (Bonus)
To prevent similar conflicts in the future, consider the following best practices:
* **Strict Include Rules**: In `nginx.conf`, prefer using `include /etc/nginx/conf.d/*.conf;` instead of a wildcard `*`. This ensures that backup files like `.bak` or `.save` are not accidentally loaded by Nginx.
* **Clean Up Deprecated Configs Promptly**: Configurations for offline sites should be moved out of the configuration directory or renamed to `.conf.disabled`.
* **Modular Management**: Use a separate `.conf` file for each independent domain or subdomain (like `wiki.lib00`), keeping the structure clean and easy to maintain.
Related Contents
Resolving PHP "could not find driver" Error: Ultimate Guide to Missing PDO Database Drivers
Duration: 00:00 | DP | 2026-07-04 08:03:00Resolving Nginx Permission Denied (13) Errors for WebP Images Generated by PHP Imagick
Duration: 00:00 | DP | 2026-07-05 21:17:00How to Fix Mac mini Not Receiving SMS Messages and iCloud Sync Stuck
Duration: 00:00 | DP | 2026-07-06 22:07:00Fixing Nginx 500 Error: Internal Redirection Cycle (SPA vs PHP Config)
Duration: 00:00 | DP | 2026-07-02 21:45:50Empowering the Full Chain with AI Agents: A Complete Architecture Guide
Duration: 00:00 | DP | 2026-07-24 09:18:05Fixing 'Unable to locate package openjdk-17-jdk' in PHP 8 Docker (Debian Trixie)
Duration: 00:00 | DP | 2026-07-25 09:23:18Nginx Reverse Proxy Guide: Elegantly Routing Specific Subdirectories to Docker Containers
Duration: 00:00 | DP | 2026-07-26 21:31:06DevOps Practice: How to Safely Clear Logs of a Running Docker Container?
Duration: 00:00 | DP | 2026-07-27 09:33:42Ultimate Guide to Setting Up Proxies on CentOS: Global Configuration and Troubleshooting
Duration: 00:00 | DP | 2026-07-27 21:36:19Say Goodbye to Line-by-Line Deletion: A Guide to Efficiently Bulk Editing and Cleaning Crontab on Linux
Duration: 00:00 | DP | 2026-07-30 09:49:20How to Fix Nginx Resource Domain CORS and 403 Forbidden Errors
Duration: 00:00 | DP | 2026-07-31 09:54:32The Ultimate Guide to Docker Cron Logging: Host vs. Container Redirection - Are You Doing It Right?
Duration: 00:00 | DP | 2026-01-05 08:03:52Cron Job Failing? The Ultimate Guide to Fixing 'docker: command not found'
Duration: 00:00 | DP | 2026-08-01 09:59:44The Ultimate 'Connection Refused' Guide: A PHP PDO & Docker Debugging Saga of a Forgotten Port
Duration: 00:00 | DP | 2025-12-03 09:03:20One-Command Website Stability Check: The Ultimate Curl Latency Test Script for Zsh
Duration: 00:00 | DP | 2025-12-07 23:25:50How Can a Docker Container Access the Mac Host? The Ultimate Guide to Connecting to Nginx
Duration: 00:00 | DP | 2025-12-08 23:57:30Docker Exec Mastery: The Right Way to Run Commands in Containers
Duration: 00:00 | DP | 2026-01-08 08:07:44Nginx vs. Vite: The Smart Way to Handle Asset Path Prefixes in SPAs
Duration: 00:00 | DP | 2025-12-11 13:16:40Recommended
NVM/Node Command Not Found in New macOS Terminals? A Two-Step Permanent Fix!
00:00 | 197A comprehensive guide to fixing the common "comman...
Is Attaching a JS Event Listener to 'document' Bad for Performance? The Truth About Event Delegation
00:00 | 167This article addresses a common JavaScript perform...
Git Pull Failed? Easily Fix the 'Your local changes would be overwritten' Error
00:00 | 223Have you ever encountered the 'error: Your local c...
Linux Command-Line Magic: 3 Ways to Instantly Truncate Large Files
00:00 | 232Need to quickly clear the contents of a huge log o...