Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

nginx warning: conflicting server name "example.com" on 0.0.0.0:80, ignored

Technical article
Hosting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

The message conflicting server name "example.com" on 0.0.0.0:80, ignored means two server blocks that listen on the same address and port both list the name example.com in server_name. nginx keeps the first one it reads and ignores the name in the later block. Because nginx logs it as a warning, our own reading is that the configuration test still passes and nginx still starts, so the fault shows up as a site that answers with the wrong content. The fix is to find both blocks and leave the name in one of them.

What the error means

In the nginx 1.30.8 source, nginx builds a table of server names for each address and port pair. It adds the names of every server block that listens on that pair, in the order the blocks were read. If a name is already in the table, the add call returns a "busy" result and nginx logs the line at the warn level: conflicting server name "%V" on %V, ignored. The first %V is the name and the second is the listen address and port.

Our own reading of the same source: the name already in the table stays, so the block read first keeps it and the block read later loses it. The later block is not removed. It can still serve requests that reach it by another name, or as the default server.

The nginx documentation on server names says the search for a request's name "terminates on the first matching variant" and lists the order: the exact name, the longest wildcard starting with an asterisk, the longest wildcard ending with an asterisk, then the first matching regular expression in order of appearance in the configuration file. A request whose Host header matches no name goes to the default server of that address and port, and the documentation says that without a default_server parameter "the first server with the address:port pair will be the default server".

Our own reading of the source loop: names written as regular expressions (starting with a tilde) are skipped by this table, so this warning is about exact and wildcard names.

Likely causes

Cause What you see How to confirm
A stale copy of a site file sits in an included directory The same name appears in two files; the stale one may be read first The name appears in two files in the output of nginx -T
The same site is enabled twice, for example a file and a link to it One warning for each name the second block repeats The same server block text appears twice in the output of nginx -T
Two sites list the same alias, such as www.example.com The warning names the alias, not the main name Search the dump for the alias
A redirect block and a content block both list the name on port 80 The redirect or the content never appears Two blocks with listen 80 list the name
A catch-all block lists a real name in server_name The default site answers for a name that has its own block The catch-all block lists the name

Prove the cause before changing anything

All of these steps only read.

1. Read the warning in full. Run the configuration test. The nginx documentation describes -t as a check of syntax that "then tries to open files referred in the configuration".

nginx -t

Write down every conflicting server name line. Each one gives the name and the address and port. A warning is not a failure, so the test can still report that the syntax is ok.

2. Dump the configuration. The nginx documentation describes -T as "same as -t, but additionally dump configuration files to standard output".

nginx -T

Search the output for the name from the warning, and for every listen line with the same address and port. You are looking for two server blocks, in two places or in one file, that both list the name. Note which of the two blocks comes first in the dump, and which file each sits in.

3. Check what the include line matches. The include directive adds "files matching the specified mask". Our own reading: a file with an extra ending such as .old is matched by a mask that ends in an asterisk but not by one that ends in .conf. Read the include lines in the dump to see which files are pulled in.

4. See which block answers. Request the site and compare the response with what you expect from the block you want to win. Use the headers first.

curl -I http://example.com/

The curl manual describes -I as fetching "the headers only".

Fix

The fix is a decision about which block owns the name, then one edit. Choose the route that matches what step 2 found.

A stale or duplicate file

The file is in an included directory but should not be. Moving it out of that directory keeps its contents, and the move is also the save: the only copy then sits under a dated name outside any directory nginx reads. The mv(1) page describes the command as "move (rename) files".

Risk: the next command takes a site file out of the directory nginx reads. If that file was the one serving traffic, the site will change or stop answering once nginx reloads. The configuration in memory does not change until the reload step below.

mv /etc/nginx/conf.d/example-old.conf /root/example-old.conf.2026-12-04

Risk: copying the saved file back puts the second block into the directory nginx reads. The name returns to two blocks, and the warning returns with it.

Only if you need to back out before the reload: copy the saved file back to its old place. The GNU manual says "cp copies files (or, optionally, directories)."

cp -p /root/example-old.conf.2026-12-04 /etc/nginx/conf.d/example-old.conf

One name listed in the wrong block

The name belongs to one block only. Edit the file that should lose it.

First save the current state. Copy the file to /root/, which no include line reads:

cp -p /etc/nginx/conf.d/example.conf /root/example.conf.2026-12-04

Risk: the next edit removes a name from a server_name line. Requests for that name will go to a different block, or to the default server, after the reload.

Open the file in an editor and delete the name from its server_name line. Leave the name in the block that should answer for it.

Risk: copying the saved file over the edited one discards the edit. The duplicate name returns.

Only if you need to back out before the reload: copy the saved file over the edited one.

cp -p /root/example.conf.2026-12-04 /etc/nginx/conf.d/example.conf

Test, then reload

Run the test first, on its own.

nginx -t

The warning lines for the name should be gone. If the test fails, stop and use the back-out above.

The copies made above are the saved state. Keep them until the reload has been checked.

Disruptive step: the next command tells the master process to load the configuration from disk and start new worker processes. The Beginner's Guide says that if the new configuration fails, the master process "rolls back the changes and continues to work with the old configuration", so a failed reload leaves the old configuration running. A successful reload changes which block answers for the name straight away.

nginx -s reload

Risk: the back-out below restores the saved file over the live one and then loads it with a second reload. The change you made is lost, and the answering block changes again.

Only if you need to back out after the reload, restore the saved file. Run only the one that applies.

For the stale file route:

cp -p /root/example-old.conf.2026-12-04 /etc/nginx/conf.d/example-old.conf

For the edit route:

cp -p /root/example.conf.2026-12-04 /etc/nginx/conf.d/example.conf

Then run the test on its own.

nginx -t

Then load the restored file with a second reload.

nginx -s reload

Example (illustrative): on web01, nginx -t prints two warnings: conflicting server name "example.com" on 0.0.0.0:80, ignored and conflicting server name "www.example.com" on 0.0.0.0:80, ignored. nginx -T shows /etc/nginx/conf.d/example-old.conf read before /etc/nginx/conf.d/example.conf, and both list server_name example.com www.example.com; under listen 80;. The old file points at a folder that was archived last month, so the site returns the wrong page. The administrator saves the old file, moves it out of conf.d, runs nginx -t with no warnings, and reloads. A request to http://example.com/ now returns the headers of the current site.

Confirm the fix

  1. nginx -t prints no conflicting server name line.
  2. nginx -T shows the name in one server block for that address and port.
  3. curl -I http://example.com/ returns the response of the block you meant to keep.
  4. Request the other names of the same site, such as the www form, and check that each returns the same site or the redirect you designed.

What to watch afterwards

Risks and limits

  • These commands have not been run or lab-tested.
  • The warn level and the wording come from the nginx 1.30.8 source. Other versions may log a different level or text.
  • The message text carries the name and the address, not the file. Use nginx -T to find the files.
  • If the wrong certificate appears for a name rather than the wrong content, see Browser shows the wrong certificate for a site: SNI and the default virtual host.
  • Moving or editing a site file on a production server changes what visitors see at reload. Our own advice: make the change outside busy hours.

Sources