GrepBoard/Manuals
605 manuals ·

Fix nginx "conflicting server name ... on 0.0.0.0:80, ignored"

·Tested on nginx 1.30.6·1.31.8 (Docker) · Ubuntu 24.04 nginx 1.24.0 · 2026-10·Test scope ↓·6 steps

nginx "conflicting server name ... ignored": two server blocks share a name on one address:port and the later is ignored. Find it with nginx -T.

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

Two or more server blocks on the same address and port (0.0.0.0:80) declare server_name example.com. The block read first keeps the name; the name in the later block is ignored. It is only a warning, so nginx -t passes — which is why it often explains "I edited the config and nothing changed". On Ubuntu the usual cause is a backup file left in sites-enabled/.

[1] Read every warning line. You get one per name and address:port, so with listen [::]:80; as well the same name appears twice.

output
nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignorednginx: [warn] conflicting server name "example.com" on [::]:80, ignorednginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

Different ports do not conflict. The same example.com on 80 and on 8080 passed with no warning.

[2] Check which block actually answers. Here both blocks have example.com, and only the second also has www.example.com:

console
$ curl -s -H 'Host: example.com' http://127.0.0.1/first$ curl -s -H 'Host: www.example.com' http://127.0.0.1/second

example.com went to the first block (first); the second block only got the name that did not overlap. If an edit has no effect, you may be editing the ignored block.

[3] Find the file and line for each copy of the name. nginx -T prints every included file and marks each with a # configuration file line.

console
$ sudo nginx -T 2>/dev/null | grep -nE "^# configuration file|server_name"
output
189:# configuration file /etc/nginx/sites-enabled/default:235:	server_name _;272:#	server_name example.com;282:# configuration file /etc/nginx/sites-enabled/example.com:285:    server_name example.com;289:# configuration file /etc/nginx/sites-enabled/example.com.bak:292:    server_name example.com;

Line 272 starts with #, so it is a comment and does not count. The conflict is between example.com and example.com.bak.

[4] On Ubuntu, look for copies in sites-enabled/. The packaged nginx.conf reads the two directories differently:

output
59:	include /etc/nginx/conf.d/*.conf;60:	include /etc/nginx/sites-enabled/*;

conf.d only loads files ending in .conf, but sites-enabled loads every file. A example.com.bak, example.com~ or example.com.orig made before an edit becomes live config.

console
$ ls -l /etc/nginx/sites-enabled/
output
lrwxrwxrwx 1 root root 34 … default -> /etc/nginx/sites-available/defaultlrwxrwxrwx 1 root root 38 … example.com -> /etc/nginx/sites-available/example.com-rw-r--r-- 1 root root 86 … example.com.bak

Normal entries in sites-enabled are symlinks (->) into sites-available. A regular file there is suspect.

[5] Move the copy out of sites-enabled. Moving instead of deleting keeps a way back.

console
$ sudo mv /etc/nginx/sites-enabled/example.com.bak /root/$ sudo nginx -t
output
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

Once the warning is gone, apply it with sudo systemctl reload nginx. To undo, move the file back into sites-enabled/, test and reload.

[6] If the split was intentional, merge it. Typical cases: the same name in both conf.d/ and sites-enabled/, or the same alias (www. and so on) in two site files. Keep the name in one block and remove it from the other block's server_name line. If the goal was a catch-all, do not reuse names — use listen 80 default_server;.

If nginx fails to start because of a long name, see could not build server_names_hash; for port errors see bind() Address already in use.

Analyze your Nginx log in the browser ↗ — nothing is uploaded.

#nginx#server_name#conflicting-server-name#sites-enabled