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

September 5, 2014 1.7k 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
@ AAAA 1111:1111::1111:(the IPv6 address, basically)
www CNAME @

Help? Thanks in advance!

  • I just pinged website.com and it pings correctly to

    But when I pinged www.website.com it couldn't find host www.website.com.

  • On a quick look, that all looks fine to me. DNS can take quite awhile to propagate completely. How long was it between the last time you tested it and the last time you changed the DNS entries?

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.