I mistakenly asked this question in stackoverlow however, it probably makes more sense here.

My application is on amazon and i am using their EC2 loadbalancer. Amazon states on their site:

DNS Name: XXXXXXXX.us-east-1.elb.amazonaws.com
Note: Because the set of IP addresses associated with a LoadBalancer can change over time, 
you should never create an "A" record with any specific IP address. If you want to use a friendly 
DNS name for your LoadBalancer instead of the name generated by the Elastic Load Balancing 
service, you should create a CNAME record for the LoadBalancer DNS name. For more information 
about CNAME records, see the CNAME Record Wikipedia article.

I created a CNAME record host www mapping to the loadbalancer above in the DNS. http://www.mydomain.com forwards to the right appserver. (Cool)

However, I noticed that when I type mydomain.com instead of http://www.mydomain.com it goes to the default A record which is mapped to a different IP and not the loadbalancer. How do I fix this? I want both www.mydomain.com and mydomain.com to go to the same loadbalancer. I think I need to do this in the DNS, right?

Note: I verified the above by pinging both addresses.

1 Answer 1


I want both www.mydomain.com and mydomain.com to go to the same loadbalancer.

You can't. This is a known design limitation, which comes from a combination of how Amazon Elastic Load Balancer (ELB) is implemented and long standing design choices for DNS.

You cannot make a CNAME entry for your naked 2nd level domain. I.e. yourdomain.com must be an A-Record pointing directly to an IP address.

However, Amazon's ELB depends on a custom DNS & EC2 platform created by Amazon, which requires your DNS entry to be a CNAME pointing to your Amazon ELB domain name (i.e. XXXXXXXX.us-east-1.elb.amazonaws.com).

Taken together, what this basically means is that you can only use 3rd level domain names with ELB, for example www.yourdomain.com or blog.yourdomain.com . And these have to be CNAMES, pointing to your ELB instance.

So for the naked 2nd level domain yourdomain.com (@) itself you must:

Just about any decent domain registrar or DNS host should have a free or very cheap way of doing this. You could also do it yourself, by running an EC2 instance with a webserver on it, but why bother...

I don't know GoDaddy's UI for this looks, as I have never used them myself. But f.x. Gandi has free-of-charge HTTP redirection called "Web Forwarding", and GoDaddy seems to have a "Site Redirect Manager".

In real life, this isn't really an issue for end users. After a short while all search engine indexing and all end user bookmarks will point to www.yoursite.com, so the number of users who enter through yoursite.com and get redirected will be tiny. And for those users, it's a short delay (maybe 100-200 ms), and it should only happen once.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .