Successfully redirect non-www url to www url but site doesn't pull up (Ubuntu 14.04 Nignx LEMP)

September 5, 2014 3.3k views

Hi, I managed to successfully forward non-www to www address on my site. So if I type website.com it’ll automatically go to www.website.com.

However, the site doesn’t pull up anything. It shows error “Server not found” “Browser can’t find the server at www.website.com. When I type in the IP address, it pulls up just fine.

BTW, I’m very newbie to using Ubuntu and building a server from scratch like this (DigitalOcean style), so any help is appreciated. I searched through articles and questions in Community section but none of the answers manage to get the site to pull up.

This is my virtualhost file setting:

server {
     listen 80;
     server_name website.com;
     return 301 $scheme://www.website.com$request_uri;
}

server {
     listen 80 default_server;
     listen [::]:80 default_server ipv6only=on;
     root /var/www/website.com/html;
     server_name www.website.com;
     ............the rest of the code settings...........
     ...................
}

I then restarted nginx with

sudo service nginx restart

I also set up the DNS to be:

@ A 111.111.111.11
@ AAAA 1111:1111::1111:(the IPv6 address, basically)
www CNAME @

Help? Thanks in advance!

2 comments
2 Answers

Hi, I took it out at noon because I was experimenting with CNAME to see if that’d solve the problem. The www CNAME was propagated since yesterday morning until this morning and nothing came up at www.website.com. I filed a ticket a few hours ago and they made the same recommendation as yours to wait a few hours to see if it’s propagated correctly. I guess I’m going to sit it out for a few more hours or maybe until tomorrow noon and see if the problem solves by itself. Thanks!

Well, you and the support team are correct. It finally propagated and the site works well now. I don’t know why it didn’t work yesterday the whole day but I’m happy that it does now. Thank you very much! :)

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!