gjivanya
gjivanya

Reputation: 589

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

When I'm trying to restart nginx, I'm getting the following error

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

I used my deploy scripts, to do deploying for 2 domains. For first it works fine, but for second, it gives error.

Here is my nginx.conf file

#
worker_processes 2;

#
user nginx nginx;

#
pid /opt/nginx/pids/nginx.pid;
error_log /opt/nginx/logs/error.log;

#
events {
    worker_connections  4096;
}

#
http {
    #
    log_format full_log '$remote_addr - $remote_user $request_time $upstream_response_time '
                        '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

    #
    access_log  /opt/nginx/logs/access.log;

    ssl on;
    ssl_certificate /opt/nginx/cert/example.crt;
    ssl_certificate_key /opt/nginx/cert/example.key;

    #
    include /opt/nginx/conf/vhosts/*.conf;

    # Deny access to any other host
    server {
        server_name example.io;  #default
        return 444;
    }
}

Upvotes: 6

Views: 21068

Answers (4)

Maksud Alam
Maksud Alam

Reputation: 249

Any how your domain name is added in

/etc/nginx/sites-enabled/default

To confirm search using

grep -r mydomain.com /etc/nginx/sites-enabled/*

and remove the domain name.

Then restart Nginx using

sudo systemctl restart nginx

Upvotes: 1

Rohit Ramani
Rohit Ramani

Reputation: 954

I had got the same problem. To resolve this, I looked for conflict domain "example.io" in conf files.

In the following file, there was a snippet added for "example.io" at the bottom. "default_server" server section was as it is but section was added at the end of the file.

/etc/nginx/sites-available/default

server {
       listen 80;
       listen [::]:80;

       server_name example.io;

       root /var/www/html;
       index index.html;

       location / {
               try_files $uri $uri/ =404;
       }
}

So I think you need to search server_name in all files which reside inside "/etc/nginx/sites-available" folder.

Upvotes: 1

yattara
yattara

Reputation: 61

Juste change listen 80 to another number like 8000 or 5000, whatever but not 80. For good job, don't edit nginx.conf itself, create your own file.conf and link it. following this link. to see clearly what i means.

Upvotes: 0

Roshan Negi
Roshan Negi

Reputation: 21

Not sure,but try changing server name in

/etc/nginx/sites-enabled/default

it should help

Upvotes: 1

Related Questions