HomeBlog

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

5 min read
Google Cloud Run custom domain setup guide header image
By David Muraya • April 14, 2025

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.

For more details, see the official Google Cloud Run custom domains documentation.

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" 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. For more info on other DNS records, check out Cloudflare's DNS Records article.

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:

Screenshot showing completed custom domain mappings in Google Cloud Run dashboard

Important Considerations

Before you go all-in on this method, there are a few limitations to keep in mind:

  • Preview Status: Direct domain mapping in Cloud Run is a preview feature. Google advises that it might have latency issues and is not recommended for production-critical services. For production, using a dedicated load balancer is a more robust option.
  • Certificate Management: Google automatically provides and renews a free SSL certificate. You cannot upload your own custom certificate. Also, you can't disable older TLS versions (1.0, 1.1). If you need stricter TLS control, you'll have to use Firebase Hosting or a Cloud Load Balancer.
  • Domain and Path Rules: Your custom domain mapping cannot be longer than 64 characters. You can only map to the root of your service (/), not a specific path like /blog. Wildcard domains (*.yourdomain.com) are also not supported with this method.
  • Regional Availability: This feature only works in specific Google Cloud regions, including us-central1, us-east1, europe-west1, and asia-northeast1. If your service is hosted elsewhere, you must use a different mapping option.

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.

Frequently Asked Questions (FAQ)

  • How long does DNS propagation take? DNS propagation can take up to 48 hours, but it's usually much faster—often within a few hours. If your site isn't working right away, give it some time and check your DNS records for typos.

  • Is Cloud Run suitable for static sites? Yes. While Cloud Run is often used for dynamic backends, it can also serve static frontends like React or Vue. You can learn how to do this in my guide on serving a React frontend with FastAPI.

  • Can I use a subdomain with Cloud Run? Absolutely. You can map subdomains (like blog.yourdomain.com) to your Cloud Run service by adding the appropriate DNS records and domain mappings in the Cloud Run console.

  • What if HTTPS doesn't work after setup? SSL/TLS provisioning can take up to 30 minutes or more. If HTTPS isn't working after that, check your DNS records for errors and review Cloud Run's documentation for troubleshooting tips.

  • Do I need to pay extra for domain mapping on Cloud Run? No, domain mapping itself is free. You only pay for your domain registration and any Cloud Run usage beyond the free tier.

  • Can I use www and non-www versions of my domain? Yes, you can map both www.yourdomain.com and yourdomain.com to your Cloud Run service. Just follow the steps for adding a www subdomain mapping.

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.

Want to learn more about deploying FastAPI apps to Cloud Run? Read my step-by-step guide here. Once your app is live, you might also want to look into advanced performance tuning.

About the Author

David Muraya is a Solutions Architect specializing in Python, FastAPI, and Cloud Infrastructure. He is passionate about building scalable, production-ready applications and sharing his knowledge with the developer community. You can connect with him on LinkedIn.

Related Blog Posts

Enjoyed this blog post? Check out these related posts!

Function Calling in Google Gemma3
Advanced Performance Tuning for FastAPI on Google Cloud Run

Advanced Performance Tuning for FastAPI on Google Cloud Run

From Cold Starts to Concurrency: A Deep Dive into FastAPI Performance on Cloud Run.

Read More..

Connecting FastAPI to a Database with SQLModel

Connecting FastAPI to a Database with SQLModel

A practical guide to building CRUD APIs with FastAPI and SQLModel.

Read More..

Running Database Migrations with Alembic in Google Cloud Build

Running Database Migrations with Alembic in Google Cloud Build

How to Organize and Load FastAPI Settings from a .env File Using Pydantic v2

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.