Configure request timeout for services

If a service runs for too long, the system takes steps to terminate or throttleit.

For Cloud Run services, the request timeout setting specifies thetime within which a response must be returned by services deployed toCloud Run. If a response isn't returned within the time specified, thenetwork connection to the service will be closed and an error 504 is returned.Note that the container instance that served the request is not terminated.The container or code might keep processing the terminated request and mighthave its execution time interfere with processing other requests. To avoid this,prevent timeouts in your service with the following techniques:

  • Set a timeout higher than your expected execution time.
  • Track the amount of time left during execution. Then perform cleanup andreturn early.

Timeout period for services

The timeout is set by default to 5 minutes(300 seconds) and can be extended up to60 minutes(3600 seconds).

When triggering your service fromEventarc events,Pub/Sub push subscriptionsorCloud Scheduler, the timeoutof these services apply.

Important: For a timeout longer than 15 minutes, Googlerecommends implementing retries and making sure the service is tolerant toclients re-connecting in case the connection is lost (either by ensuring requestsare idempotent, or by designing request handlers in such a way that they canresume from the point where they left off).The longer the timeout is, the more likely the connection can be lost due tofailures on the client side or the Cloud Run side.When a client re-connects, a new request is initiated and the client isn'tguaranteed to connect to the same instance of the service.

You can change this setting when you deploy a container image or by updatingthe service configuration.

In addition to changing the Cloud Run request timeout, you should alsocheck your language framework to see whether it has its own request timeoutsetting that you must also update. Some clients of the Cloud Runservice might also impose a more restrictive timeout.

Required roles

To get the permissions that you need to configure and deploy Cloud Run services, ask your administrator to grant you the following IAM roles:

If you are deploying aserviceorfunction from source code, youmust also have additional roles granted to you on your project andCloud Build service account.

For a list of IAM roles and permissions that are associated withCloud Run, seeCloud Run IAM rolesandCloud Run IAM permissions.If your Cloud Run service interfaces withGoogle Cloud APIs, such as Cloud Client Libraries, see theservice identity configuration guide.For more information about granting roles, seedeployment permissionsandmanage access.

Set and update request timeout

Any configuration change leads to thecreation of a new revision. Subsequent revisions will also automatically getthis configuration setting unless you make explicit updates to change it.

You can set request timeout using the Google Cloud console, the gcloud CLIcommand line, or a YAML file when youcreate a new service ordeploy a new revision.

Console

  1. In the Google Cloud console, go to Cloud Run:

    Go to Cloud Run

  2. SelectServices from the Cloud Run navigation menu, and clickDeploy container to configure a new service.If you are configuring an existing service, click theservice, then clickEdit and deploy new revision.

  3. If you are configuring a new service, fill out the initial servicesettings page, then clickContainer(s), Volumes, Networking, Security to expand theservice configuration page.

  4. Click theContainer tab.

    image

    • In theRequest timeout field, enter the timeout value that you want to use in seconds. Use values ranging from1 to3600 seconds, or from 1 to60 minutes.
  5. ClickCreate orDeploy.

gcloud

You canupdate the request timeoutfor a given revision at any time by using the following command:

gcloudrunservicesupdateSERVICE--timeout=TIMEOUT

Replace the following:

You can also set the request timeout duringdeployment using the command:

gcloudrundeploy--imageIMAGE_URL--timeout=TIMEOUT

Replace the following:

  • IMAGE_URL: a reference to the container image, forexample,us-docker.pkg.dev/cloudrun/container/hello:latest. If you use Artifact Registry,therepositoryREPO_NAME mustalready be created. The URL follows the format ofLOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/PATH:TAG.
  • TIMEOUT: the time within which a response must bereturned, using an integer value or a duration value—for example,1m20swhich is 1 minute, 20 seconds. If you use an integer value, the unit isassumed to be seconds. The value you specify must be less than60 minutes.

YAML

  1. If you are creating a new service, skip this step.If you are updating an existing service, download itsYAML configuration:

    gcloudrunservicesdescribeSERVICE--formatexport>service.yaml
  2. Update thetimeoutSeconds attribute:

    apiVersion:serving.knative.dev/v1kind:Servicemetadata:name:SERVICEspec:template:spec:containers:-image:IMAGEtimeoutSeconds:VALUE

    Replace the following:

    • SERVICE: the name of your Cloud Run service.
    • IMAGE_URL: a reference to the container image, forexample,us-docker.pkg.dev/cloudrun/container/hello:latest. If you use Artifact Registry,therepositoryREPO_NAME mustalready be created. The URL follows the format ofLOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/PATH:TAG.
    • VALUE: the chosen timeout, in seconds.
  3. Create or update the service using the following command:

    gcloudrunservicesreplaceservice.yaml

Terraform

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.

Add the following to agoogle_cloud_run_v2_service resource in your Terraform configuration:

resource"google_cloud_run_v2_service""default"{name="cloudrun-service-request-timeout"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{containers{image="us-docker.pkg.dev/cloudrun/container/hello"}    # Timeouttimeout="300s"}}

Replace300s with your service's chosen request timeout.

View request timeout settings

To view the current request timeout settings for yourCloud Run service:

Console

  1. In the Google Cloud console, go to the Cloud RunServices page:

    Go to Cloud Run

  2. Click the service you are interested in to open theService detailspage.

  3. Click theRevisions tab.

  4. In the details panel at the right, the request timeout settingis listed under theContainer tab.

gcloud

  1. Use the following command:

    gcloudrunservicesdescribeSERVICE
  2. Locate the request timeout setting in the returnedconfiguration.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.