HomeBlog

How to Set Up a Custom Domain for Your Google Cloud Run App

5 min read

David Muraya Blog Header Image

If you're hosting your website on Google Cloud Run, you might want to use your own domain name instead of the default URL Google gives you. It's not hard to set up, and it makes your site look more professional. In this post, I'll walk you through how to add a custom domain to your Cloud Run service, keeping it simple and cheap.

Prerequisite: I'm assuming you've already set up your Cloud Run service in a Google Cloud Platform project. If you haven't, check out my earlier article on setting up Cloud Run.

Step 1: Verify Domain Ownership

Before Google lets you use your domain with Cloud Run, you need to prove you own it. This happens through Google Search Console. Here's what to do:

  1. Go to Google Search Console and add your domain as a property.
  2. Pick the "Domain" option and type in your domain name (like "yourdomain.com").
  3. Google will give you a TXT record—a short string of text you need to add to your domain's DNS settings.
  4. Log in to your domain registrar (like GoDaddy or Namecheap), find the DNS settings, and paste in that TXT record.
  5. Back in Search Console, hit "Verify." It usually takes 2-5 minutes to confirm.

Note: You'll need access to your registrar's DNS management page. If you're stuck, their help docs should point you in the right direction.

Step 2: Set Up Custom Domain Mapping in Cloud Run

Once your domain is verified, you can connect it to Cloud Run. Here's how:

  1. Open the Cloud Run console and pick your service.
  2. Look for "Manage Custom Domains" (the label might be slightly different) and click it.
  3. Hit "Add Mapping" and choose the domain you verified.
  4. Google will show you eight DNS records: four A records and four AAAA records. These link your domain to Cloud Run's servers.
  5. Go back to your registrar's DNS settings and add all eight records exactly as shown.
  6. Return to Cloud Run and finish the mapping process.

What's this A and AAAA stuff? A records connect your domain to IPv4 addresses, and AAAA records do the same for IPv6. Cloud Run uses multiple addresses for reliability, so you get four of each.

Tip: After adding the records, you can check if they're working with a tool like "dig" or an online DNS checker.

Step 3: Add a www Subdomain (Optional)

Want your site to work with www.yourdomain.com too? It's an extra step, but easy.

  1. In Cloud Run, add another mapping, this time for www.yourdomain.com.

  2. Google will give you a CNAME record instead of A or AAAA records.

  3. Add that CNAME record to your registrar's DNS settings.

  4. Finish the mapping in Cloud Run.

What's a CNAME? It's like a shortcut - it points www.yourdomain.com to your main Cloud Run address.

Step 4: Wait for SSL/TLS Provisioning

After setting up the DNS records, Google handles the security part by creating an SSL/TLS certificate. This makes your site use HTTPS, which is a must these days. It takes about 30 minutes, though sometimes a bit longer. You'll see the status update in Cloud Run when it's done. While it's processing, your site might not load, or you might see browser warnings. That's normal - just wait it out.

Here is how your mappings will appear after you have correctly followed the steps above:

David Muraya GCP Custom Domain Mappings

Costs

Here's the breakdown:

  • Domain: About $10-15 per year, depending on your registrar and domain type.

  • Cloud Run: There's a free tier that covers a decent amount of usage. After that, you pay only for what you use-requests, CPU, and memory. For small sites, it's often pennies a month.

The domain mapping itself? Free. No hidden fees there.

Things you need to watch out for

  • DNS Delays: Propagation can take up to 48 hours, but it's usually faster.

  • Typos: Mess up a DNS record, and your site won't work. Double-check them.

  • Subdomains: If you're mapping something like blog.yourdomain.com, make sure you set it up right.

  • SSL Issues: If HTTPS doesn't kick in, peek at Cloud Run's docs or ask for help online.

Wrapping Up

That's it! Once everything's set, your website will run on your custom domain with HTTPS, all hosted on Cloud Run. It's a cheap way to get a professional setup - just the cost of your domain and whatever Cloud Run usage you rack up beyond the free tier.

Related Blog Posts

Enjoyed this blog post? Check out these related posts!

Optimizing Reflex Performance on Google Cloud Run

Optimizing Reflex Performance on Google Cloud Run

A Comparison of Gunicorn, Uvicorn, and Granian for Running Reflex Apps

Read More..

Adding middleware to FastAPI Applications: Process Time, Security, and Compression

Adding middleware to FastAPI Applications: Process Time, Security, and Compression

A practical guide to implementing middleware in FastAPI for better performance, security, and efficiency.

Read More..

Deploying Reflex Front-End with Caddy in Docker

Deploying Reflex Front-End with Caddy in Docker

A step-by-step guide to building and serving Reflex static front-end files using Caddy in a Docker container

Read More..

Simple CI/CD for Your FastAPI App with Google Cloud Build and Cloud Run

Simple CI/CD for Your FastAPI App with Google Cloud Build and Cloud Run

Push code, deploy automatically: A simple CI/CD guide for your web app.

Read More..

Contact Me

Have a project in mind? Send me an email at hello@davidmuraya.com and let's bring your ideas to life. I am always available for exciting discussions.

© 2025 David Muraya. All rights reserved.