nginx- duplicate default server error

2020-05-14 04:43发布

In my error log i get

[emerg] 10619#0: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/mysite.com:4

on Line 4 I have:

server_name mysite.com   www.mysite.com;

Any suggestions?

标签: nginx
4条回答
别忘想泡老子
2楼-- · 2020-05-14 04:51

You likely have other files (such as the default configuration) located in /etc/nginx/sites-enabled that needs to be removed.

This issue is caused by a repeat of the default_server parameter supplied to one or more listen directives in your files. You'll likely find this conflicting directive reads something similar to:

listen 80 default_server;

As the nginx core module documentation for listen states:

The default_server parameter, if present, will cause the server to become the default server for the specified address:port pair. If none of the directives have the default_server parameter then the first server with the address:port pair will be the default server for this pair.

This means that there must be another file or server block defined in your configuration with default_server set for port 80. nginx is encountering that first before your mysite.com file so try removing or adjusting that other configuration.

If you are struggling to find where these directives and parameters are set, try a search like so:

grep -R default_server /etc/nginx
查看更多
Deceive 欺骗
3楼-- · 2020-05-14 05:03

If you're on Digital Ocean this means you need to go to /etc/nginx/sites-enabled/ and then REMOVE using rm -R digitalocean and default

It fixed it for me!

Pic of Console on Windows 10 using Bitvise

查看更多
Emotional °昔
4楼-- · 2020-05-14 05:04

Execute this at the terminal to see conflicting configurations listening to the same port:

grep -R default_server /etc/nginx
查看更多
趁早两清
5楼-- · 2020-05-14 05:09

OS Debian 10 + nginx. In my case, i unlinked the "default" page as:

  1. cd/etc/nginx/sites-enabled
  2. unlink default
  3. service nginx restart
查看更多
登录 后发表回答