The request timeout setting specifies the time within which a response must be returned by services deployed to Cloud Run. If a response isn't returned within the time specified, the request ends and error 504 is returned.
By default, the timeout is set to 5 minutes.
You can change this setting when you deploy a container image or by updating the service configuration.
In addition to changing the Cloud Run request timeout, you should also check your language framework to see whether it has its own request timeout setting that you must also update.
Setting and updating request timeout
Any configuration change leads to the creation of a new revision. Subsequent revisions will also automatically get this configuration setting unless you make explicit updates to change it.
Note that timeouts greater than 15 minutes are a Beta feature.
Click Create Service if you are configuring a new service you are deploying to. If you are configuring an existing service, click on the service, then click Edit and Deploy New Revision.
Under Advanced Settings, click Container.
In the Request timeout field, enter the timeout value that you want to use in seconds. The following ranges are available:
Use values ranging from
15minutes). Although you can specify values up to 60 minutes, timeouts greater than 15 minutes are a Beta feature.
Click Create or Deploy.
You can update the request timeout for a given revision at any time by using the following command:
gcloud run services update [SERVICE] --timeout=[TIMEOUT]
[SERVICE]with the name of your service.
[TIMEOUT]with the desired time, using an integer value or an absolute duration value, for example
1m20swhich is 1 minute, 20 seconds. If you use an integer value, the unit is assumed to be seconds. The value you specify must be less than 60 minutes. Note that timeouts greater than 15 minutes are a Beta feature and require you to use the
gcloud beta runcommand.
You can also set the request timeout during deployment using the command:
gcloud run deploy --image IMAGE_URL --timeout=[TIMEOUT]
IMAGE_URLwith a reference to the container image, for example,
[TIMEOUT]with the desired time, using an integer value or a duration value, for example
1m20swhich is 1 minute, 20 seconds. If you use an integer value, the unit is assumed to be seconds. The value you specify must be less than 60 minutes. Note that timeouts greater than 15 minutes are a Beta feature and require to use the
gcloud beta runcommand.
You can download and view existing service configuration using the
gcloud run services describe --format export command, which yields
cleaned results in YAML format. You can then modify the fields described below and
upload the modified YAML using the
gcloud beta run services replace command.
Make sure you only modify fields as documented.
To view and download the configuration:
gcloud run services describe SERVICE --format export > service.yaml
apiVersion: serving.knative.dev/v1 kind: Service metadata: name: SERVICE spec: template: spec: containers: - image: IMAGE timeoutSeconds: VALUE
- SERVICE with the name of your Cloud Run service
- IMAGE with the URL of your container image.
- VALUE with the desired timeout, in seconds.
Replace the service with its new configuration using the following command:
gcloud beta run services replace service.yaml