Question

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

  • Posted September 5, 2014

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!

Subscribe
Share

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?

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

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


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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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! :)

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!