This page describes the common troubleshooting strategies for Cloud Run
errors. [Personalized Service Health](https://docs.cloud.google.com/service-health/docs/overview.md.txt) publishes
all Cloud Run incidents that stem from the
underlying Google Cloud infrastructure to identify Google Cloud service disruptions
impacting your projects. You should also consider [setting up alerts on Personalized Service Health events](https://docs.cloud.google.com/service-health/docs/configure-alerts-dashboard.md.txt). For information
about incidents affecting all Google Cloud services, see the [Google Cloud Service Health](https://status.cloud.google.com/summary) dashboard.

See the following sections in the [Cloud Run troubleshooting guide](https://docs.cloud.google.com/run/docs/troubleshooting.md.txt) for resolving issues related to your Cloud Run resource:

- [Deployment errors](https://docs.cloud.google.com/run/docs/troubleshooting.md.txt#deployment)
- [Serving errors](https://docs.cloud.google.com/run/docs/troubleshooting.md.txt#serving)
- [Connectivity and security errors](https://docs.cloud.google.com/run/docs/troubleshooting.md.txt#connectivity)

## Cloud Run troubleshooting strategies

The following sections explain how you can apply general troubleshooting
strategies to resolve your error. If you continue to encounter errors even after
following the steps in the [troubleshooting](https://docs.cloud.google.com/run/docs/troubleshooting.md.txt) guide,
see [What's next](https://docs.cloud.google.com/run/docs/troubleshooting/overview.md.txt#next-steps).

### Output good logs using Cloud Logging

Troubleshooting your Cloud Run resource is easier if you have good logs for debugging. You should write logs in a way that
[correlates your container logs with a request log](https://docs.cloud.google.com/run/docs/logging.md.txt#correlate-logs).

With correlated logs, you can identify the request that needs further analysis,
find the request trace, and analyze the root cause of the issue. For more
information on writing logs, see [Write container logs](https://docs.cloud.google.com/run/docs/logging.md.txt#container-logs).

### Investigate instances using the Logs Explorer

Each request log in Cloud Run contains an [`instanceId`](https://docs.cloud.google.com/run/docs/logging.md.txt#service-fields) field that identifies an instance that handles your
request. Depending on the [concurrency value](https://docs.cloud.google.com/run/docs/about-concurrency.md.txt) you
specify, a single instance can handle multiple requests at the same time.

When you have multiple instances emitting logs at once, you should filter your
instances to identify the sequential requests that lead up to an instance crash.

Filtering an instance lets you debug specific performance issues related
to cold starts or increased latencies. These issues could also be bound to
variables declared in a global scope, when the value is reused in subsequent
concurrent requests. An example of this is when you create a single connection
pool global object for the instance, and then use it within multiple requests.

To filter a specific instance in the Logs Explorer, follow these steps:

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

   [Go to Logs Explorer](https://console.cloud.google.com/logs/query)
2. Select an existing Google Cloud project at the top of the page, or create a
   new project.

3. Select the resource **Cloud Run Revision** for a service, or
   **Cloud Run Job** for a job.

4. Expand a log entry to filter by a specific instance.

5. Click the instance ID value, and select **Show matching entries**.

While you investigate instances, you can [use Gemini Cloud Assist Investigations](https://docs.cloud.google.com/run/docs/troubleshooting/overview.md.txt#use-investigations) to gain additional insights into your logs.
For more information about different ways to initiate an
investigation by using the Logs Explorer, see
[Troubleshoot issues with Gemini Cloud Assist Investigations](https://docs.cloud.google.com/cloud-assist/investigations.md.txt#entry-points) in the Gemini documentation.

### Resolve unexpected request latencies

If you encounter issues with latency, do the following:

1. Check if the latency is affecting all requests to your Cloud Run
   resource or only a small percentage. Cloud Run is automatically integrated with Cloud Monitoring **with no setup or configuration required.**

   To see individual request latency metrics, follow these steps:
   1. In the Google Cloud console, go to the Cloud Run page:

      [Go to Cloud Run](https://console.cloud.google.com/run)
   2. Select a service or a job from the lists available in left navigation.

   3. Click the **METRICS** tab to show the **Request latencies** dashboard.

   To [view latency metrics in Cloud Monitoring](https://docs.cloud.google.com/run/docs/monitoring.md.txt#view-metrics-cloud-monitoring), select from the **Metrics** list,
   **Cloud Run Revision \> Request_latencies \> Request latency**.

   For a list of all available Cloud Run metrics and more in-depth
   details, see [Google Cloud metrics](https://docs.cloud.google.com/monitoring/api/metrics_gcp_p_z.md.txt#gcp-run) in Cloud Monitoring.
2. Identify the request with high latency to understand the source of latency.
   You can use Cloud Trace or Cloud Logging to understand how long a
   particular request has taken.

   To identify requests with high latency using Cloud Logging, apply the `traceSampled=true` filter to correlate logs in Cloud Logging with traces
   in Cloud Trace. For more information, see [Integrate with Cloud Logging](https://docs.cloud.google.com/trace/docs/trace-log-integration.md.txt).

   Sometimes dependencies such as requests to other services might cause latency
   issues. To identify such requests, you should have explicit logging targeting
   the requests. If you don't output such logs, it could appear as a latency
   issue originating from a Cloud Run service.

   Additionally, you should consider evaluating latency spikes in the context of
   the chosen time window. A spike's significance is relative; a large spike
   in a small window might be negligible in a larger window, and vice-versa.
   Therefore, the time window significantly impacts the interpretation of
   latency data.
3. Try increasing the number of [minimum instances](https://docs.cloud.google.com/run/docs/configuring/min-instances.md.txt#setting-service-level) to reduce latency for incoming requests,
   and avoid cold starts. You should also consider modifying your source code,
   and [adjust the scaling settings](https://docs.cloud.google.com/run/docs/configuring/max-instances.md.txt) to
   limit the number of connections to a backing service.

   For more information, see [Optimizing performance](https://docs.cloud.google.com/run/docs/tips/general.md.txt#optimize_performance).

### Troubleshoot connectivity issues

If your Cloud Run service is experiencing connectivity issues, consider
these strategies and tools to diagnose the problem:

- [PCAP sidecar](https://github.com/GoogleCloudPlatform/pcap-sidecar): For deeper
  network-level analysis, [deploy a PCAP sidecar](https://docs.cloud.google.com/run/docs/deploying.md.txt#multicontainer-yaml) alongside your
  Cloud Run service. This sidecar container performs a packet capture
  using `tcpdump` within the same network namespace. The sidecar decouples
  from the main ingress container and doesn't require any modifications to
  perform a packet capture. Sidecars also use their own resources, which
  prevents `tcpdump` from competing with the resources you allocate to the
  primary service.

- Network intelligence and connectivity tests for [Cloud Run
  revisions](https://docs.cloud.google.com/network-intelligence-center/docs/connectivity-tests/how-to/running-connectivity-tests#testing-cr)
  and
  [Cloud Run functions](https://docs.cloud.google.com/network-intelligence-center/docs/connectivity-tests/how-to/running-connectivity-tests.md.txt#testing-cloudfunction):
  Perform automated checks on the network path between your Cloud Run
  resource and an endpoint. This helps you find
  misconfigurations that might block traffic to or from your Cloud Run
  resource when connecting to a VM instance, an IP address, or a Google-managed
  service.

- [Review logs](https://docs.cloud.google.com/run/docs/troubleshooting/overview.md.txt#investigate-instances) for your Cloud Run resource:
  Logs show error messages about connection problems, such as failures,
  timeouts, or refused connections. These logs often reveal if the connection
  issue is with your application or the network.

### Troubleshoot with SSH

> [!WARNING]
>
> **Preview
> --- SSH support for Cloud Run**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

SSH for Cloud Run lets you establish a secure, interactive shell
connection to your container instances. This provides direct access to the
container's file system and runtime environment, enabling you to inspect system
resources, verify configurations, and troubleshoot. For more information, see
[Troubleshoot Cloud Run with SSH](https://docs.cloud.google.com/run/docs/troubleshooting/ssh.md.txt).

### Troubleshoot with Gemini assistance

<br />

> [!WARNING]
>
> **Preview**
>
>
> This product or feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section
> of the [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products and features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

You can use [Gemini Cloud Assist](https://docs.cloud.google.com/cloud-assist/overview.md.txt)
chat to analyze logs and troubleshoot errors. With Gemini assistance, you
can quickly pinpoint and resolve errors by leveraging the tool's log analysis
capabilities, saving valuable time and effort.

To use Gemini Cloud Assist from the Google Cloud console, do
the following:

1. [Ensure that Gemini Cloud Assist is set up for your Google Cloud user account and project](https://docs.cloud.google.com/cloud-assist/set-up-gemini.md.txt).

2. [Set up your Cloud Run development environment](https://docs.cloud.google.com/run/docs/setup.md.txt)
   in your Google Cloud project and ensure you have the appropriate
   [deployment permissions](https://docs.cloud.google.com/run/docs/reference/iam/roles.md.txt#additional-configuration).

3. Go to the Cloud Run page in the Google Cloud console.

   [Go to Cloud Run](https://console.cloud.google.com/run)
4. In the console toolbar, select a Google Cloud project. Use a project
   associated with a project ID you submitted after you were granted access to
   Gemini Cloud Assist.

5. Click spark
   **Open or close Gemini AI chat**.

   The Gemini panel opens.
6. If necessary, click **Accept** if you agree to the terms.

7. If you have a question about a specific application, provide context by
   going to the page that shows your resource before asking your question. When
   generating a response, Gemini includes information about the
   current console page and project.

8. Enter a prompt in the **Gemini** panel.

   The following table provide some example prompts for using
   Gemini Cloud Assist with Cloud Run.

   | **Prompt** | **Type of response** |
   |---|---|
   | "Can you explain this error message I'm seeing in my Cloud Run container logs?" | Without a specific error message in the prompt, the output provides troubleshooting guidance for common Cloud Run container log error messages. |
   | "Can you explain this error message I'm seeing in my logs for my Cloud Run service? <br /> `HTTP 429 The request was aborted because there was no available instance. The Cloud Run service might have reached its maximum container instance limit or the service was otherwise not able to scale to incoming requests. This might be caused by a sudden increase in traffic, a long container startup time or a long request processing time."` | Explanation of the Cloud Run error message and how to address the error. |
   | "How do I fix the following error message when deploying my Cloud Run service? <br /> `HTTP 404: Not found` | Common causes of the error and how to troubleshoot the error. |
   | "My Cloud Run service keeps crashing. What could be causing this?" | Approach for investigating the cause and how to address the problem. |
   | "How do I know if a 5XX error surfaced in the logs was due to a Google infrastructure service outage?" | Steps for determining the cause of the 5XX error. |
   | "How do I identify the cause of this error: `com.google.apps.framework.request.BadRequestException Project PROJECT has serving status SYSTEM_DISABLED and cannot be modified`?" | Suggests that the Google Cloud project has been administratively disabled at the system level. Provides steps to investigate the cause further. |
   | "Why can I access my Cloud Run service from a browser if I have set `ingress=internal`?" | An explanation of the expected behavior when configuring the `ingress` setting to `internal`. Includes other scenarios where access might seem to work from your browser. |

For more details, see the following resources:

- Learn how to [write better prompts](https://docs.cloud.google.com/gemini/docs/discover/write-prompts.md.txt).
- Learn how to use the [Gemini Cloud Assist panel](https://docs.cloud.google.com/cloud-assist/chat-panel.md.txt).
- Read [Use Gemini for AI assistance and development](https://docs.cloud.google.com/gemini/docs/overview.md.txt).
- Learn [how Gemini for Google Cloud uses your data](https://docs.cloud.google.com/gemini/docs/discover/data-governance.md.txt).

### Use Gemini Cloud Assist Investigations

In addition to interactive chat, Gemini Cloud Assist can perform more
automated, in-depth analysis through
[Gemini Cloud Assist Investigations](https://docs.cloud.google.com/cloud-assist/investigations.md.txt).
This feature is integrated directly into workflows like
Logs Explorer, and is a powerful root-cause analysis tool.

When you initiate an investigation from an error or a specific resource,
Gemini Cloud Assist analyzes logs, configurations, and metrics.
It uses this data to produce ranked observations and hypotheses about probable
root causes, and then provides you with recommended next steps. If you have a
[support package](https://cloud.google.com/support), you can also transfer the
investigation results to a Google Cloud support case, providing additional
context that can help resolve your case faster.

For services or functions deployed from [source code](https://docs.cloud.google.com/run/docs/deploying-source-code.md.txt),
investigations can also provide code fix suggestions in the
Cloud Run console's "Source" tab to help you resolve build and
deployment issues.

For more information about different ways to initiate an investigation, see
[Troubleshoot issues with Gemini Cloud Assist Investigations](https://docs.cloud.google.com/cloud-assist/investigations.md.txt#entry-points) in the Gemini documentation.

### What's next

If you can't find a solution to your problem in the Cloud Run
documentation, follow these steps:

- Open a support case by contacting [Cloud Customer Care](https://cloud.google.com/support-hub).
- Get support from the community by [asking questions on StackOverflow](https://stackoverflow.com/questions/tagged/google-cloud-run), or search for similar issues using the `google-cloud-run` tag.
- Open bugs or feature requests by using the [public issue tracker](https://docs.cloud.google.com/support/docs/issue-trackers.md.txt).