Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

Adding a Custom Domain to Your Site on Gatsby Cloud

Introduction

Gatsby Cloud allows you to specify Custom Domains for your Gatsby websites. This guide provides the steps for applying Custom Domains to your sites on Gatsby Cloud.

Prerequisites

Before you can add a custom domain, you’ll need to be hosting with Gatsby Cloud. If you haven’t already, turn on Gatsby Hosting.

Directions

1. Add a domain

  1. Go to Site Settings > Hosting.
  2. Click “Add Domain” above the domain list to start the process
    Click Add Domain
  3. In the “Please enter a domain” field, add one of the following:
  • your apex or root domain (this is your custom domain without the www. part, e.g. mysite.com)
  • your subdomain (e.g., www.mysite.com or store.mysite.com)
    Enter your domain

Whichever one you choose will become the primary domain for your site.

Redirect to the primary domain

If you add an apex domain, Gatsby Hosting will automatically add a redirect that points the www. subdomain to the apex domain. Similarly, if you add a www. subdomain, Gatsby Hosting will automatically add a redirect that points the apex domain to it. Read more about redirected domains in Working with Redirected Domains.

2. Configure your domain name system (DNS)

Next you’ll need to visit your 3rd party DNS registrar (e.g. GoDaddy, NameCheap, etc.) to add some DNS records. A DNS Record is an entry in a DNS with details about how to route a request for a given domain name.

Apex domain configuration

If you added an apex domain, you will need to add an Address Mapping Record (A Record).

  1. Copy one of the IP addresses from the “Value” column for the A records shown next to your custom domain.
  2. In your DNS provider’s domain settings, create an A Record for the IP address you chose.
    Copy IP Address for A Record

The A Record must point to one of the IP addresses shown for your site. It is only necessary to create an A Record for one of the IP addresses listed.

Subdomain configuration

If you added a subdomain, you will need to add a Canonical Name Record (CNAME). The CNAME record must point to the default domain for your site.
Configure a subdomain

Here’s documentation on adding DNS records for some popular name registrars:

3. Check DNS status

Once you’ve added your DNS record, click “Check Status” or refresh the page to check that your DNS record has been recognized by Gatsby Hosting.
Check DNS Status

If your domain fails to validate after 24 hours, try creating an A Record for one of the other IP addresses available instead.
Domain failed to validate

4. Generate SSL certificate

After the domain is validated, we’ll generate a free SSL certificate via Let’s Encrypt and automatically configure it. This whole process can take a few minutes to complete.
Generating SSL Certificate

Note: DNS records need to be fully propagated in order to properly verify the certificates. If not, SSL certification generation will fail.

SSL certificates generated by Gatsby will automatically update with no action required on your end. If you add a custom SSL certificate, you will need to generate and reupload a new certificate before the current certificate expires.

5. Finish

Once your custom domain has the “HTTPS On” label next to it, you should be able to visit it to see your site live.
Confirm site is successfully connected

If you encounter errors related to the the connection not being secure, please allow a few minutes as it can take time for DNS changes to take effect and be detected by all browsers. Use this time to verify that you followed the above steps completely.

Other considerations

If you see the following when you visit your custom domain, the site may still be building.
Site is still building

Check the “Deploys” tab for your site to see the current status of your builds.
Latest build status

Start building today on Netlify!
Edit this page on GitHub
© 2024 Gatsby, Inc.