---
title: "Which path does this Cloud Run revision use to reach Cloud SQL? | Proofline"
description: "Before you read the error, read the path: the revision's annotations list the routes it has, and the code's settings say which one it takes."
url: https://proofline.sh/learn/which-path-cloud-run-uses-to-reach-cloud-sql/
---

[Learning center](/learn/)

# Which path does this Cloud Run revision use to reach Cloud SQL?

Before you read the error, read the path: the revision's annotations list the routes it has, and the code's settings say which one it takes. A Unix socket under /cloudsql/, a language connector, a private IP over the VPC and a public IP each need different settings and fail in different ways, so the path decides which checks apply.

Network outages The Proofline team November 23, 2026 6 min read

## Why the path comes first

The same timeout or refusal points to different owners on different paths. A missing Cloud SQL Client role breaks the socket and the connectors, and does nothing to a direct TCP connection to the private IP. A firewall rule in the VPC breaks the private IP path and does nothing to the socket. Reading the wrong path's settings sends the investigation to an owner who cannot fix it. [The four stages](/learn/cloud-run-cloud-sql-connection-errors/#stage) apply to every path, but what sits at each stage differs.

Cloud SQL offers two connection types: a Cloud SQL connector (the Cloud SQL Auth Proxy or a language connector for Java, Python, Go or Node.js), or a direct connection to the instance's private or public IP address. Cloud Run embeds the Cloud SQL Auth Proxy for public IP connections. [Connection options](https://cloud.google.com/sql/docs/postgres/connect-overview)

## The paths and what each one needs

| Path | What the revision carries | What the code uses | Needs from IAM and APIs | Needs from the network |
| --- | --- | --- | --- | --- |
| Built-in connection, Unix socket | `run.googleapis.com/cloudsql-instances` lists the instance | A socket path under `/cloudsql/INSTANCE_CONNECTION_NAME` | Cloud SQL Client on the revision's service account; Cloud SQL Admin API enabled | None in the VPC |
| Language connector, public IP | Nothing specific | A connector library and the connection name, IP type public | Cloud SQL Client; Admin API enabled | Egress on 443 to the Admin API and 3307 to the instance |
| Language connector, private IP or PSC | VPC egress: `run.googleapis.com/network-interfaces` or `run.googleapis.com/vpc-access-connector` | A connector with IP type private or PSC | Cloud SQL Client; Admin API enabled | A route to the instance's private address or PSC endpoint |
| Direct TCP, private IP | VPC egress as above | A host that is the instance's private IP, port 5432 | None for the path; the database login still applies | A route, firewall rules that allow it, and the right egress setting |
| Direct TCP, PSC endpoint | VPC egress as above | The endpoint's internal IP or DNS name | None for the path | A route to the endpoint in the consumer network |
| Direct TCP, public IP | Usually nothing | The instance's public IP | None for the path | Authorized networks that include the source address |

The sources for each row: the built-in connection mounts the socket and needs Cloud SQL Client and the Admin API [Connect from Cloud Run](https://cloud.google.com/sql/docs/postgres/connect-run). The Auth Proxy and the connectors call the Admin API on port 443 for an ephemeral certificate and connect to the instance on port 3307, and need a role with `cloudsql.instances.connect` [About the Auth Proxy](https://cloud.google.com/sql/docs/postgres/sql-proxy). The private IP path uses TCP to the instance on port 5432 without the Auth Proxy [Connect with TCP](https://cloud.google.com/sql/docs/postgres/connect-run#private-ip_1). PSC endpoints are internal IP addresses in the consumer's VPC network, reached by address or DNS record [Private Service Connect](https://cloud.google.com/sql/docs/postgres/about-private-service-connect). A direct public IP connection needs authorized networks [Connection options](https://cloud.google.com/sql/docs/postgres/connect-overview).

## Check 1: read what the revision carries

```
gcloud run revisions describe REVISION \
  --project PROJECT --region REGION \
  --format='yaml(metadata.annotations, spec.serviceAccountName, spec.containers[0].env)'
```

Look for four annotations. `run.googleapis.com/cloudsql-instances` sets the Cloud SQL connections; `run.googleapis.com/vpc-access-connector` sets a Serverless VPC Access connector; `run.googleapis.com/vpc-access-egress` sets `all-traffic` or `private-ranges-only`; and `run.googleapis.com/network-interfaces` holds the network and subnet for Direct VPC egress. [Revision template annotations](https://cloud.google.com/run/docs/reference/rest/v1/RevisionTemplate) · [Direct VPC egress YAML](https://cloud.google.com/run/docs/configuring/vpc-direct-vpc)

A revision can carry several of these at once. The annotations say which routes exist; they do not say which one the code takes.

## Check 2: read what the code connects to

The connection setting decides the path. Read it from the revision's `env` and secrets, and from the code where the pool is built:

| The host or connection setting | Path |
| --- | --- |
| A path that starts with `/cloudsql/` | Built-in Unix socket |
| A connection name `project:region:instance` passed to a connector library, such as `cloud-sql-python-connector`, the Java socket factory or `cloudsqlconn` in Go | Language connector; read its IP type next |
| An address in a private range, or a DNS name that resolves to one | Direct TCP over the VPC: the instance's private IP or a PSC endpoint |
| A public address | Direct TCP to the public IP |

For a connector, the IP type decides the network path. Google's samples select it from an environment variable: the Python sample uses `IPTypes.PRIVATE` when `PRIVATE_IP` is set and `IPTypes.PUBLIC` otherwise, and the Java sample sets `ipTypes` to `PUBLIC,PRIVATE` as a preference list. [Connect with Cloud SQL connectors](https://cloud.google.com/sql/docs/postgres/connect-run#connect-connectors) · [Language connectors](https://cloud.google.com/sql/docs/postgres/connect-connectors)

To tell an instance's private IP from a PSC endpoint, read the instance:

```
gcloud sql instances describe INSTANCE --project INSTANCE_PROJECT \
  --format='yaml(connectionName, ipAddresses, settings.ipConfiguration.ipv4Enabled, settings.ipConfiguration.privateNetwork, settings.ipConfiguration.pscConfig)'
```

`ipAddresses` lists the instance's addresses with a type: `PRIMARY` is the address clients are meant to connect to, and `PRIVATE` is the private IP used with network peering. `privateNetwork` names the VPC that reaches the private IP, and `pscConfig` holds PSC settings. [Instance resource](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances) An address the code uses that appears in neither list is a PSC endpoint or something else in your network.

## A worked fixture: same symptom, two paths

The fixture is illustrative. The fictional service `orders-api` in `europe-west1` reaches `shop-prod:europe-west1:orders-db`, which has a public and a private address. `orders-api-00018` takes all traffic at 09:12:30 UTC, and requests that read the database time out.

**Outcome A: the code changed paths.** Both revisions carry the same annotations: `cloudsql-instances: shop-prod:europe-west1:orders-db` and no VPC egress. `orders-api-00017` connects through `/cloudsql/shop-prod:europe-west1:orders-db`. `orders-api-00018` switched to the Python connector, and its environment sets `PRIVATE_IP=true`.

| Revision | Annotations | Code setting | Path |
| --- | --- | --- | --- |
| `orders-api-00017` | `cloudsql-instances` | Socket under `/cloudsql/` | Built-in socket |
| `orders-api-00018` | `cloudsql-instances` | Connector, IP type private | Connector to the private IP, with no VPC egress |

The new code asks for a path the revision cannot route. Remove `PRIVATE_IP` or add VPC egress; either way, the decision belongs to the release. IAM was never involved: the same service account worked on the socket path a minute earlier.

**Outcome B: the path stayed, the network changed.** Both revisions carry `network-interfaces` for network `shop-vpc`, subnet `run-europe-west1`, egress `private-ranges-only`, and both set `DB_HOST=10.40.0.3`, which matches the instance's `PRIVATE` address. `orders-api-00017`'s new instance at 09:14 times out as well.

| Revision | Path | New instance connects? |
| --- | --- | --- |
| `orders-api-00017` | Direct TCP, private IP | No (09:14:05) |
| `orders-api-00018` | Direct TCP, private IP | No (09:12:44) |

The path did not change and the old revision fails too. A Cloud SQL Client role or the Admin API cannot explain a timeout on this path, because no proxy or connector is in it. Read the VPC: firewall rules, the peering and the subnet. [Private IP connections from Cloud Run time out](/learn/cloud-run-cloud-sql-private-ip-timeout/)

## Where the checks mislead

A connector configured with a preference list, such as Java's `PUBLIC,PRIVATE`, can take a different path when the instance's addresses change. Read the instance's `ipAddresses` for the window as well as the code.

The `cloudsql-instances` annotation can stay on revisions whose code no longer uses the socket. Its presence proves only that the socket is mounted.

A Java application can use the connector without the built-in connection, so a revision with no annotation can still depend on the Cloud SQL Client role and the Admin API. [Console steps](https://cloud.google.com/sql/docs/postgres/connect-run#console)

## Questions

### Does Cloud Run use the Cloud SQL Auth Proxy?

For the built-in Cloud SQL connection, yes: Cloud Run embeds the Auth Proxy for public IP connections and exposes it as a Unix socket under `/cloudsql/`. A direct TCP connection to the private IP does not use it.

### Does a private IP connection from Cloud Run need the Cloud SQL Client role?

Not for the path itself when the code connects by TCP to the private address. If the code uses a language connector with the private IP type, the connector still authorizes through IAM and the Cloud SQL Admin API.

### Can one revision use two paths?

Yes. A revision can carry the socket and VPC egress at the same time, and different parts of the code, such as a migration job and the request pool, can use different settings. Read every place a pool is built.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Cloud Run cannot reach Cloud SQL: revision, identity or connection?](/learn/cloud-run-cloud-sql-connection-errors/)
    
    Broken dependencies The Proofline team November 23, 2026 9 min read
    
-   ### [Private IP connections from Cloud Run to Cloud SQL time out](/learn/cloud-run-cloud-sql-private-ip-timeout/)
    
    Network outages The Proofline team November 23, 2026 6 min read
