Default URL for Cloud Run instances

By default, every Cloud Run instance receives a default run.app URL when created. This unique, addressable URL has the following format:

https://INSTANCE_NAME-PROJECT_NUMBER.REGION.run.app

Replace the following:

  • INSTANCE_NAME: the name of the Cloud Run instance.
  • PROJECT_NUMBER: the Google Cloud project number.
  • REGION: the name of the region, such as europe-west1.

If you want to remove access to the default URL endpoint, you can disable it. To further secure your instance from public access, you can also configure ingress settings to control and restrict network access. See instructions for configuring ingress settings for Cloud Run instances.

When you disable the default URL, Cloud Run restricts ingress to private and Virtual Private Cloud paths, while maintaining an individual URL per instance.

Disable the default URL for Cloud Run instances

Disable the default run.app URL of a Cloud Run instance to only allow traffic from the instance's other ingress paths: Cloud Load Balancing and any configured domain mapping.

gcloud

  • For an existing instance, run the gcloud beta run instances update command with the --no-default-url flag, for example:

    gcloud beta run instances update INSTANCE --no-default-url
  • For a new instance, run the gcloud beta run instances deploy command with the --no-default-url flag, for example:

    gcloud beta run instances deploy INSTANCE \
        --image IMAGE_URL \
        --no-default-url

    Replace INSTANCE with the name of your Cloud Run instance.

    In the output, the URL displays as None.

To restore the default URL, use the --default-url flag.

YAML

  1. If you are creating a new instance, skip this step. If you are updating an existing instance, download its YAML configuration:

    gcloud beta run instances describe INSTANCE --format export > instance.yaml
  2. To disable the default URL, set the run.googleapis.com/default-url-disabled annotation to 'true':

    apiVersion: run.googleapis.com/v1
    kind: Instance
    metadata:
      name: INSTANCE
      annotations:
        run.googleapis.com/default-url-disabled: 'true'
        run.googleapis.com/launch-stage: BETA
    spec:
      containers:
      - name: CONTAINER_NAME
        image: IMAGE_URL

    Replace the following:

    • INSTANCE: the name of your Cloud Run instance.
    • CONTAINER_NAME: the name of the container.
    • IMAGE_URL: a reference to the container image, such as us-docker.pkg.dev/cloudrun/container/hello:latest.
  3. Create or update the instance using the following command:

    gcloud beta run instances replace instance.yaml

To restore the default URL, set the run.googleapis.com/default-url-disabled annotation to false or remove it.

What's Next

See Restrict network endpoint ingress for more details and instance configuration instructions.