8

I am in the process of setting up MX records on a HEROKU hosted app and am running into issues.

I have two CNAME's setup:

@ myapp.herokuapp.com
www myapp.herokuapp.com

Site works fine as setup above. I am now trying to add email support by adding Google Apps MX records.

@ ASPMX.L.GOOGLE.COM.  MX 10 1800  

--as well as four other MX fall backs--

Google Apps is saying it can't read the MX records. Is this because they are conflicting with the @ CNAME record? If so, should I drop that and used the "Naked Domain" method (Setup three A records instead). Heroku makes it sounds like this method is highly discouraged vs CNAMEs for "@" non WWW.

Thanks for the help!

cman77
  • 1,573
  • 1
  • 20
  • 45
  • They won't conflict. Can you supply your domain name? I assume you have waited for your DNS provider to push your new records out (15-20 minutes at some providers) before checking with Google? – elithrar Jul 28 '12 at 08:06

4 Answers4

10

I found the best way to do this is to use Google Apps "Naked Domain" 301 Redirect Feature as described in https://support.google.com/a/answer/2518373?hl=en

1) Go to Admin Console - Domains - Change Naked Redirect

2) Redirect to WWW.your_domain.com

3) You will setup 4 A-Records in your DNS pointing your your_domain.com to

  • 216.239.32.21
  • 216.239.34.21
  • 216.239.36.21
  • 216.239.38.21

Now, when somebody points to your_domain.com they get 301 redirected to WWW.your_domain.com This, btw is the same way gooogle.com behaves (301 redirect to www.google.com)

HT: http://smallchou.com/post/41388058201/heroku-and-root-aka-apex-or-naked-domains

Leo Tulipan
  • 171
  • 1
  • 6
  • 1
    I am also using Google Apps for Work for email and Heroku for our website. I was previously relying on Network Solutions to redirect the naked domain, but that doesn't appear to work any more. I followed your suggestion and it is working great. Thanks. – Ryan Aug 04 '15 at 21:31
3

Apparently they conflict. From Heroku:

Hi, you can't have CNAME entries on the zone apex. 
You'll need to do the A records setup, or use a DNS provider that 
supports ALIAS/ANAME records (DNSimple, DNS Made Easy, Route 53).

Removing the @ CNAME and replacing it with A records seemed to work - within minutes Google picked up my MX records.

Final setup was a single WWW CNAME pointing to myapp.herokuapp.com. and three A records, each pointing to one of the Heroku listed IPs.

cman77
  • 1,573
  • 1
  • 20
  • 45
2

I was just struggling with something like this. When I switched to Heroku I added the CNAME to point my root domain (my_domain.com) to heroku and that link I guess forwards everything and kills your MX records for email, so the way I solved it was to instead point just my www subdomain to heroku via cname record (www.my_domain.com), and then I added a link forwarding my root domain (my_domain.com) to my subdomain (www.my_domain.com). Then my MX records worked again, but I had to wait a few hours for it to start working (luckily I gave up and went to bed and then in the morning realized it had worked). To point the root to the www subdomain, my domain name provider had a setting called pointers, and the options I selected were 'standard', 'URL' and 'www.my_domain.com'

Then to get SSL to work I had to add a redirect in the backend webserver code to redirect http to https, so I guess now if you type my_domain.com it redirects to www.my_domain.com and then redirects to https.my_domain.com, so kinda crazy but it works super fast so I guess it's good.

Jesse Adamson
  • 331
  • 3
  • 5
0

If your DNS provider supports ALIAS (Namecheap now does) you can easily get both email (MX, TXT records) and use the naked url (example.com, instead of www.example.com) with heroku.

Instead of choosing CNAME record type, pick ALIAS. Namecheap example of advanced DNS line would be like this:

(Type)            (Host)           (Value)                                (TTL)
ALIAS Record      @                heroku-weird-dns-target.herokudns.com  5 min

ALIAS will play along with both TXT and MX.

VM4
  • 5,663
  • 5
  • 33
  • 48