DNS and namecheap domain tools

I just wanted to share some hints on how to make an avil app work on a domain when you use the namecheap domain management tools. First, credits: Thanks to Anvil and Meredydd for help.

In short:

  1. Have a domain name (with ssl registered) at namecheap
  2. In their dashboard, click on the domain name and then select Advanced DNS
  3. Under host records add a type A record with the value Anvil tells you to add (52.56.203.177)
  4. If they exist, delete the existing redirects and www host records
  5. Add a type CNAME record with www and the value anvil.works

The end result should include the first and last record in this picture (the middle CNAME is specific to my domain and SSL):

3 Likes

Is adding both the CNAME and the A record necessary?

I tend to only add the CNAME.

Aha. You are probably right. The key is that the A Record is not enough (as it is in some other places and described in the docs). Namecheap seems to require a CNAME type with www. After that everything worked well!

Also using Namecheap and trying this out…and failing.

Getting an error page with ERR_CERT_COMMON_NAME_INVALID

Any pointers? (Do I need to buy an SSL package at namecheap?)

Yes, I think anvil requires that the domain is secure (https) before you can use it to host your app which means that you need to buy SSL and install it for the domain name. But I am not sure.

I use GoDaddy and don’t need to buy any SSL package. Just follow that instruction:
https://anvil.works/docs/deployment/choosing-urls#using-your-own-domain-name

1 Like

You shouldn’t need to purchase anything else, just make sure you add the custom domain to your app in Anvil project properties (when you publish the app publicly).

Anvil can take a few hours sometimes to confirm the domain is live by email, but once done you should be good to go. I’ve done it many times without issue.

Note, there might be an error in the first description. The ip address should probably be 52.56.203.177 NOT 53.56.203.177 (I do not know if things have changed or both might be ok, but the starting value of 52 is what is suggested and I think the other was an error).

1 Like

Anvil requires that the domain name be secured (https) before you are able to use it to host your application, which means you have to purchase and install SSL for the domain name in order for it to work. It’s a little unclear to me.

I was unsure about this myself, but it seems to work without buying an SSL. I may be wrong …

Hans Olav

What if I wanted to my main domain (like example.com) to redirect to something I’m hosting a landing page on (like example.carrd.com), but still have anvil host my webapp on a subdomain (like app.example.com).

Is there a way to achieve that?

Yes, just follow the directions but use your subdomain instead of your main domain. I have a setup just like that and there was no trick to getting it working.

1 Like

Thanks, not working for me unfortunately. I thought the redirection might be the problem, because in the original post it says to delete any existing redirects (step 4). Do you have an SSL certificate installed in your setup?

SSL for Anvil apps is handled by Anvil. Have you gotten the email from Anvil saying your custom domain is setup?

No, instead I got an email from Anvil saying domain configuration is required and that the DNS records haven’t been set up yet. I do have the exact first and last record like in the screenshot of the OP though, just with my subdomain instead of the “@”.

You only need the first record, for your subdomain. The www record should point to where you’re hosting your static site. But it’s the first record that you actually need for Anvil.

Without seeing exactly what you have in both your registrar and in Anvil, it’s hard to say for sure where the mismatch is. The OP has what you should have in your registrar, so if you’ve matched that you should be good there.

In Anvil, when you setup your custom domain, it should be the full subdomain, e.g. app.example.com

If you’ve got both of those setup, you might email Anvil support and see if they can work out where the mismatch is.

1 Like

I figured it out with Anvil support. My mistake was that compared to the OP’s screenshot, on namecheap I replaced the host ("@") with “app.example.com” instead of simply “app”, which is what you should do. Thanks for your help!

2 Likes