Ffile2fix
Sign in Get started

How to fix Nginx "conflicting server name ... ignored"

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

Two server blocks listen on the same address and port and both list the same server_name. Nginx uses the first one it loads and ignores the name in the other, so your changes may seem to have no effect. It usually comes from a duplicate config file or a leftover backup in sites-enabled.

Also appears as: nginx: [warn] conflicting server name "www.example.com" on 0.0.0.0:443, ignored · nginx: [warn] conflicting server name "_" on 0.0.0.0:80, ignored · nginx: [warn] conflicting server name "example.com" on [::]:80, ignored

Common causes

  • The same site is enabled twice, for example example.com and example.com.bak in sites-enabled
  • Certbot added a server block while an old one with the same name still exists
  • A name is listed in both the default server and a site file
  • conf.d/*.conf and sites-enabled/* both include a copy of the site
  • Two separate sites accidentally share a www or alias name

How to fix it

  1. Find every block using the name. Run sudo nginx -T 2>/dev/null | grep -n 'server_name.*example.com' to search the full loaded config. Note the file each match comes from.
  2. Remove duplicates and backups. Delete or move backup files out of /etc/nginx/sites-enabled/ and /etc/nginx/conf.d/. Nginx loads every matching file there, including .bak copies when the include uses *.
  3. Merge the server blocks. Keep one block per name and port. If Certbot created a new 443 block, move any custom rules into it and delete the old duplicate.
  4. Keep names unique per port. Each name may appear once per listen address. It is fine to have example.com on port 80 (redirect) and on port 443 (site) in separate blocks.
  5. Test and reload. Run sudo nginx -t. When the warning is gone, reload with sudo systemctl reload nginx.

Find duplicate server_name entries in the loaded config

sudo nginx -T 2>/dev/null | grep -E '^# configuration file|server_name'
ls -la /etc/nginx/sites-enabled/ /etc/nginx/conf.d/

How to stop it happening again

  • Keep backups outside sites-enabled and conf.d
  • Use symlinks from sites-available instead of copies
  • Run nginx -t after every change and read the warnings
  • Use one file per site

Frequently asked questions

Is this warning harmful?

Nginx keeps running, but one of the blocks is ignored for that name. Changes you make in the ignored block will not apply, which causes confusing behavior.

Which server block does Nginx use?

The first one it loads for that address and port. Load order follows the include order and file names alphabetically.

Can I have the same name on ports 80 and 443?

Yes. The conflict only happens when the same name is on the same address and port twice.