nginx warns that a conflicting server name was ignored
nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignoredShort answer
nginx found the same server_name twice for the same address and port, so it keeps the first block and ignores the second one. It is a warning, but the ignored block never serves traffic. Dump the full config with nginx -T, find the duplicate name, then delete the copy or give each block its own name.
Fix it fast
1Find out which cause you have
Print every loaded config file and search for the name in the warning. Two hits for the same listen port are the conflict.
sudo nginx -T 2>/dev/null | grep -n "server_name\|^# configuration file"2Match what you see, then jump to its fix
- 1
The name in the warning appears in two server_name lines with the same listen portTwo server blocks use the same name on the same portFix - 2
-T shows the same file header (# configuration file ...) two timesAn include mask loads the same file twiceFix - 3
conflicting server name "" on 0.0.0.0:80, ignoredSeveral blocks have no server_name at allFix
- 1
What does the error look like?
nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignorednginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
Cause 1 of 3
Two server blocks use the same name on the same port
1Check
nginx stores names per address and port. A repeated name on that pair cannot be added, so the later block loses it. Find both blocks and the files they sit in.
sudo nginx -T 2>/dev/null | grep -n "example.com"2Fix
Remove the old duplicate (often a leftover copy of the site), or change the name in one block. Use a separate block only when the name or the port really differs.
server {
listen 80;
server_name example.com www.example.com;
# one block per name and port
}3Verify
The test prints no warn line.
sudo nginx -tConfirmed by nginx.org
Cause 2 of 3
An include mask loads the same file twice
1Check
include accepts a mask, so two masks that both match a site file load it twice. Typical case: both conf.d/*.conf and sites-enabled/* pick up one file, or a symlink and its target are both matched.
sudo nginx -T 2>/dev/null | grep -n "^# configuration file"
grep -rn "include" /etc/nginx/nginx.conf2Fix
Keep each site file under one included folder, or narrow the masks so they no longer overlap.
# in the http block, one mask per folder
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;3Verify
Run the test again; each file now appears once in the dump.
sudo nginx -t && sudo nginx -T 2>/dev/null | grep -c "^# configuration file"Confirmed by nginx.org
Cause 3 of 3
Several blocks have no server_name at all
1Check
A server block without server_name uses the empty name. Two such blocks on one port clash on that empty name.
sudo nginx -T 2>/dev/null | grep -n "listen 80\|server_name"2Fix
Give every block a real server_name, and mark exactly one block per port as the fallback with default_server in its listen line.
server {
listen 80 default_server;
server_name _;
# fallback for unknown hostnames
}3Verify
No warn line is printed by the test.
sudo nginx -tConfirmed by nginx.org
How do I stop it coming back?
- Run nginx -t after every change and read the warn lines, not only the final 'successful'.
- Keep one file per site, named after the domain, and delete the old copy when a site moves.
- Use sites-enabled symlinks or conf.d, not both for the same file.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
nginx says duplicate default server and will not load
nginx: [emerg] a duplicate default server for 0.0.0.0:80
A default server belongs to an address and port pair, so only one server block may carry default_server for each pair.
2 causes, each with a fixServers
A Let's Encrypt certificate did not renew with Certbot
Type: connection ... Timeout during connect (likely firewall problem)
Run sudo certbot renew --dry-run and read the Type and Detail lines.
6 causes, each with a fixServers
curl cannot connect to port 80 or 443 on a server running nginx
CURLE_COULDNT_CONNECT (7): Failed to connect() to host or proxy
Exit code 7 means the TCP connection itself failed, before any HTTP happened.
3 causes, each with a fixServers
Django returns a 500 behind Gunicorn and the traceback is nowhere
The traceback shows locally with runserver but not under Gunicorn
With DEBUG set to False, Django's default logging does not print errors to the console.
2 causes, each with a fixServers
Your website on a Google Compute Engine VM times out on port 80
The site works with curl on the VM but not from outside
A timeout, as opposed to a refusal, usually means a firewall dropped the packets.
3 causes, each with a fixServers
Gunicorn rejects a request with "Error parsing headers: limit request headers fields size"
Error parsing headers: 'limit request headers fields'
Gunicorn caps the size of one header field at 8190 bytes and the number of headers at 100 by default.
2 causes, each with a fix