Heroku Subdomains: A No-Holds-Barred Introductory Guide

Heroku Subdomains: A No-Holds-Barred Introductory Guide

Looking to enhance your Heroku app's professional image with a custom Heroku domain name? This comprehensive guide to Heroku subdomains has got you covered.

We'll walk you through setting up and configuring DNS records, as well as how to integrate Mailer To Go on your Heroku app for a seamless email experience. 

With statistics showing that 81% of consumers conduct online research before purchasing a product or service, having a memorable and professional URL can make all the difference to your brand. 

This comprehensive how-to guide covers the basics you need to make your Heroku app stand out from the competition. Read on!

What is a subdomain?

A subdomain is a domain that is part of a larger domain.

Subdomains are primarily used to arrange website content and services into different sections. For instance, if your company has a website domain titled "example.com." The subdomain could take the form of "blog.example.com."

Additionally, you can use a subdomain to direct traffic to specific applications or services.

Heroku is a cloud platform that provides developers with various tools for building, deploying, and scaling web applications. Heroku subdomains are a platform feature that allows you to create custom subdomains for your Heroku application. 

Looking to integrate email into your Heroku app?📨👀
Use your own addresses to send verified email from inside your Heroku apps with Mailer To Go’s streamlined and scalable add-on service.

What are the benefits of using Heroku subdomains?

Heroku subdomains are a powerful tool for customizing and branding your Heroku application and for organizing your app's content and services into distinct sections before you deploy or after.

By setting up subdomains, you can direct traffic to specific parts of your Heroku application and establish a unique brand identity that sets your app apart from the competition.

There are several benefits to using Heroku subdomains for your application:

1. Custom branding

Heroku subdomains allow you to create a custom Heroku domain name for your application, which can help enhance your brand's online presence. The ability to add custom domains is particularly useful if you have multiple applications hosted on Heroku, as it can help differentiate them from one another.

2. Easy management

Heroku subdomains can be easily managed and updated using the Heroku CLI or the Heroku Dashboard. This lets you quickly change your app's domain name without reconfiguring DNS settings like your alias and DNS record.

3. Scalability 

Heroku subdomains are designed to be scalable, meaning they can handle large amounts of traffic and requests without affecting the performance of your application.

4. Creating a brand identity 

Subdomains can help you establish a unique brand identity for your app by using a custom Heroku domain name that reflects your app's name or purpose.

creating a brand identity

Does Heroku allow subdomains?

Yes, Heroku does allow subdomains. However, there are certain policies and requirements that you must meet before you can use subdomains with your Heroku app:

  • You can purchase a custom domain from a domain registrar or use a domain you own.

  • You must first have a custom domain name to use a custom subdomain with your Heroku app.

  • Once you have a custom domain, you can set up a CNAME record that points to the DNS target for your Heroku app.

1. Steps to check if your app is eligible for a subdomain

To check if your app is eligible for a subdomain, use the Heroku CLI to run the following command: "Heroku domains."

This will display a list of domains associated with your app, including any custom domains you have set up. If you see your custom domain listed, you can set up a subdomain by creating a CNAME record that points to the DNS target for your Heroku app.

It's important to note that Heroku does not support wildcard domains. A wildcard domain is a domain that matches all subdomains for a given domain name.

2. Alternatives to Heroku subdomains

If you can't use Heroku subdomains, alternative options are available.

You can set up a URL redirect record for your domain name, redirecting traffic from one URL to another. Let's consider this example. 

This can be useful to direct traffic from a subdomain to a specific page or section of your app. On the flip side, an apex domain is the app's primary domain (e.g., "example.com" instead of "www.example.com").

To discover email security best practices, stop your emails from going to junk, learn about the mail delivery subsystem, and plenty more, please explore our latest posts.

How many sub-subdomains can a domain have?

Sub-subdomains are sometimes referred to as third-level domains. Third-level domains are classified as subdomains of subdomains.

Imagine, for instance, that you have a root domain known as 'example.com," then you can choose to create a subdomain "app.example.com" with "api.app.example.com" as the sub-sub domain.

1. Limitations on the number of sub-subdomains

Practically, you can have as many sub-subdomains as possible. However, there are some limitations to consider during the process. First, each subdomain adds complexity to your DNS configuration, making it harder to manage and maintain. Second, some DNS providers may have technical limitations on the number of subdomains or sub-subdomains they support.

sending emails

2. Best practices for organizing sub-subdomains

As a best practice, organizing your sub-subdomains logically and hierarchically is a good idea. For example, you might use sub-subdomains to organize different features or services of your Heroku application. This can make managing and maintaining your DNS configuration easier over time.

When setting up sub-subdomains for your Heroku app, you must configure the CNAME record and DNS target for each subdomain and sub-subdomain. 

This can be done using Heroku domains, your app's DNS provider, or the Heroku CLI. If you plan to use SSL with your sub-subdomains, you must also configure an SSL certificate for each domain and subdomain. 

Spend more time shooting the breeze🏖️
...and less time puzzling over complicated email services, with Mailer To Go’s full-featured cloud email add-on.

How do I add custom domain names for Heroku apps?

The process involved in adding a custom domain on a Heroku app is relatively easy and can be completed using the steps below: 

1. Purchase or use a custom domain name

The first step is to have a custom domain name that you want to use for your Heroku app. You can purchase a new domain name from a domain registrar or use a domain you already own.

2. Add the custom domain to your application

In your Heroku dashboard, navigate to your app and click the Settings tab. Navigate to the Domains section on your Heroku app, then click on the Add Domain button, fill in the custom domain name you intend to use, and click the Save Changes icon. 

3. Configure your DNS records

After adding your custom domain name to your app, you must configure your DNS records to point to Heroku. Heroku will provide you with a DNS target you'll need to add as a CNAME record with your domain's DNS provider. 

For example, if your DNS target is "example.herokuapp.com," you'll need to add a CNAME record with your domain's DNS provider that points "www" to "example.herokuapp.com."

4. Verify your domain

Once you've added your DNS record, you must verify your custom domain with Heroku. In your Heroku dashboard, navigate to your app and click the Settings tab. 

Navigate to the Domain section on your Heroku app, then click the Verify button next to the domain name.

Heroku will verify that your DNS record is correctly configured and display a green checkmark when everything is set up correctly.

5. Add an SSL certificate

You must add an SSL certificate to your Heroku app to secure your custom domain name. Heroku provides a free SSL certificate for each app, which you can add by clicking on the Configure SSL button in the Settings tab of your app's dashboard. You can also use a custom SSL certificate if you prefer.

That's it! Once you've completed these steps, your custom domain name will be set up and ready to use with your Heroku app.

adding an ssl certificate

Are subdomains hosted separately?

Yes, subdomains are typically hosted separately from the root domain. When you add a subdomain to your domain name, it becomes a separate entity with its own DNS records, hosting, and website content. This means you can use subdomains to create separate websites or applications related to your main website.

In the case of Heroku, adding a subdomain to your app means creating a separate endpoint for your app that can be accessed via the subdomain URL. Heroku handles the hosting and DNS for your app's subdomain, so you don't need to worry about setting up a separate hosting account or managing the DNS record for your subdomain.

1. Root domain DNS settings and alterations

Since subdomains are an integral part of the domain name, an alteration made on the root domain can significantly affect the subdomain. 

For example, changing the DNS settings for your root domain can also affect the DNS settings for your app's subdomain. Therefore, it's important to carefully manage your domain name and subdomains to ensure that everything is set up correctly and working as expected.

To discover email security best practices, stop your emails from going to junk, learn about the mail delivery subsystem, and plenty more, please explore our latest posts.

How do I integrate Mailer To Go on Heroku?

Integration and setup of Mailer To Go on Heroku allows you to send emails from your email addresses and domains. Follow these simple steps to seamlessly integrate Mailer To Go and enjoy a reliable, secure email-sending experience.

  • Log in to your Heroku account and navigate to your app's dashboard.

  • Click on the Resources tab.

  • In the Add-ons search bar, type "Mailer To Go" and select it from the list of available add-ons.

  • Choose the pricing plan that best suits your needs, then click the Provision button.

  • Once the add-on is provisioned, click the Settings tab and the Reveal Config Vars button.

  • The next phase is to fill in your SMTP credentials; these include your SMTP server, port username, and passcode. Additionally, you'll have to add your email address and the domain you intend to use to send your emails.

  • After entering your SMTP credentials and email information, click the Add button to save the changes.

  • Next, update your application code to use Mailer To Go. You can add the Mailer To Go credentials to your application environment variables or use the Mailer To Go library in your code.

  • Finally, you can test your email-sending functionality by sending a test email from your Heroku application.

By following these steps, you can seamlessly integrate Mailer To Go on Heroku to enjoy a reliable, secure email-sending experience.

About Mailer To Go! 📬
Mailer To Go lets you send emails from inside your Heroku applications using your own email addresses and domains.


Frequently asked questions

What are Heroku subdomains?

Heroku subdomains are unique identifiers assigned to each Heroku app. When you create an app on Heroku, it is automatically assigned a Herokuapp.com subdomain, like your-app-name.herokuapp.com. This subdomain is where your app is accessible on the web.

How can I create subdomains for all my users on Heroku?

To create custom subdomains for each of your users on Heroku, you can use a wildcard DNS record. This allows you to route all subdomains of a given domain to your Heroku app. Then, within your app, you can use middleware to handle requests based on the subdomain. Note that this requires a custom domain to be set up on your Heroku app.

How do I point a subdomain to a Heroku app?

To point a subdomain to a Heroku app, you need to add a DNS record with your domain provider. The type of record is typically a CNAME record, where the name is your subdomain and the value is your Heroku app's default domain (your-app-name.herokuapp.com).

Then, you need to add the subdomain to your Heroku app's settings in the Heroku dashboard.

Can I use multiple subdomains with one Heroku app?

Yes, you can use multiple subdomains with one Heroku app. You would need to add each subdomain to your Heroku app's settings and set up the appropriate DNS records with your domain provider. If you're using a transactional email service like Mailer To Go, they can help you manage and send emails from these subdomains.

What is a wildcard subdomain in Heroku?

A wildcard subdomain in Heroku allows you to direct all subdomains of a given domain to your Heroku app. This is done by setting up a wildcard DNS record with your domain provider and configuring your Heroku app to accept requests from any subdomain.

What are Heroku subdomains and what are their benefits?

Heroku subdomains are a feature of the Heroku cloud platform that allows you to create custom subdomains for your Heroku application. They offer benefits such as custom branding, easy management, scalability, and the ability to create a unique brand identity for your application.

How can you add custom domain names for Heroku apps?

To add a custom domain name to a Heroku app, you first need to purchase or use a custom domain name. Then, add the custom domain to your application, configure your DNS records to point to Heroku, verify your domain, and add an SSL certificate.

Using a reliable email service provider like Mailer To Go can help ensure your emails reach your customers' inboxes.

Boost Your Email ROI with Mailer To Go

Ready to boost email deliverability and clickthrough rates?

Start for free