Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX server_name not work

Tags:

nginx

I ecountered the following issue about server_name in nginx and might need your help. This is my default.cnf resided in /etc/nginx/conf.d/

server {
    listen       80;
    server_name  planner.dev;

    root   /var/www/planner.dev/src;
    index  index.php index.html index.htm;
    ...
}

And I have a helloworld html file in /var/www/planner.dev/src However, only localhost will run, planner.dev will not run.

$ curl planner.dev
curl: (6) Couldn't resolve host 'planner.dev'
like image 285
Hoang Lam Avatar asked Dec 14 '25 00:12

Hoang Lam


2 Answers

The problem is most likely in the system hosting the server, than in the server itself.

I was running an Nginx server on Debian and happened to have the same issue, which I solved by editing the /etc/hosts file likeso:

127.0.0.1       localhost
127.0.0.1       vacuum
127.0.0.1       <mywebsite>.localhost

More about the hosts file.

like image 65
Acsor Avatar answered Dec 16 '25 22:12

Acsor


The issue is fixed by editing the hosts file of Centos, not relating to NGINX. Sorry everybody

like image 27
Hoang Lam Avatar answered Dec 16 '25 22:12

Hoang Lam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!