Fix GCP Cloud Run Run Custom Domain Errors
When working with GCP Cloud Run, you may encounter a configuration error that prevents your deployment from working. This guide explains the most common mistake with run custom domain and shows the exact fix.
A Common Mistake
Mapping a custom domain to Cloud Run without verifying domain ownership, causing the mapping to fail with a domain verification error.
The incorrect command:
gcloud beta run domain-mappings create --service=my-service --domain=app.example.com --region=us-central1
Error output:
ERROR: (gcloud.beta.run.domain-mappings.create) FAILED_PRECONDITION: The domain app.example.com has not been verified. Verify ownership by adding a TXT record to your DNS configuration:
Name: _gcloud-app.example.com
Value: google-site-verification=XXXXXX
TTL: 300
The Correct Approach
The right way to configure run custom domain in GCP Cloud Run:
gcloud domains verify app.example.com && gcloud beta run domain-mappings create --service=my-service --domain=app.example.com --region=us-central1
Successful result:
Creating mapping...
Domain mapping created.
Add these DNS records:
Type: CNAME
Name: app.example.com
Value: ghs.googlehosted.com
Then wait 5-10 minutes for DNS propagation.
The service is available at https://app.example.com
How to Prevent This
Verify domains with gcloud domains verify. Use Cloud DNS for managed DNS. CNAME records must point to ghs.googlehosted.com. Domain mappings are per-region. Use a global load balancer for multi-region custom domains. Wildcard domains (*.example.com) require a special mapping.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Secure your cloud with DodaTech.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro