---
title: "The Cloud Run service account lacks Cloud SQL Client: who removed it? | Proofline"
description: "When an unchanged Cloud Run service account gets 403 notAuthorized from Cloud SQL, ask Policy Troubleshooter whether it holds cloudsql.instances.connect."
url: https://proofline.sh/learn/cloud-run-cloud-sql-client-role-missing/
---

[Learning center](/learn/)

# The Cloud Run service account lacks Cloud SQL Client: who removed it?

When an unchanged Cloud Run service account gets 403 notAuthorized from Cloud SQL, ask Policy Troubleshooter whether it holds cloudsql.instances.connect. Ask about the instance's project, then read that project's IAM audit log for the window. The answer is one of four: the role was never granted, a policy change removed it, a condition stopped matching, or a deny policy blocks it.

Permission errors The Proofline team November 23, 2026 5 min read

## How the symptom shows up

The Cloud SQL Auth Proxy behind Cloud Run's built-in connection, and the language connectors, ask the Cloud SQL Admin API for the instance's details and a certificate. The service account needs a role with `cloudsql.instances.connect`; Cloud SQL Client, Editor and Admin include it. Without it, the proxy reports a `403 notAuthorized` error. [Auth Proxy troubleshooting](https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#troubleshooting) · [Cloud SQL roles](https://cloud.google.com/sql/docs/postgres/roles-and-permissions)

This is stage 2 of [the four stages](/learn/cloud-run-cloud-sql-connection-errors/#stage). A direct TCP connection to a private IP has no proxy and does not need this role, so confirm the path first. [Which path the revision uses](/learn/which-path-cloud-run-uses-to-reach-cloud-sql/)

This guide assumes the identity did not change. Confirm it before you start; if the two revisions run as different accounts, the cause is the deploy. [A deploy changed the revision's service account](/learn/cloud-run-revision-service-account-changed/)

```
for r in PREVIOUS_REVISION NEW_REVISION; do
  gcloud run revisions describe "$r" --project PROJECT --region REGION \
    --format='value(metadata.name, spec.serviceAccountName)'
done
```

## Check 1: does the account hold the permission now?

Cloud SQL Client contains `cloudsql.instances.connect` and `cloudsql.instances.get`, and the project is the lowest level where it can be granted. [Cloud SQL IAM roles](https://cloud.google.com/iam/docs/roles-permissions/cloudsql) Check the project that holds the instance, which may not be the service's project. [An instance in another project](/learn/cloud-run-cloud-sql-other-project/)

Policy Troubleshooter evaluates a resource's effective allow and deny policies for one principal and one permission. [`troubleshoot-policy iam`](https://cloud.google.com/sdk/gcloud/reference/policy-intelligence/troubleshoot-policy/iam)

```
gcloud policy-intelligence troubleshoot-policy iam \
  //cloudresourcemanager.googleapis.com/projects/INSTANCE_PROJECT \
  --principal-email=SERVICE_ACCOUNT \
  --permission=cloudsql.instances.connect
```

To check a conditional binding at a given moment, add `--request-time` with an RFC 3339 UTC timestamp, such as the time of the first failure. Results show as Unknown for policies you lack permission to read, including deny policies if you do not have Deny Reviewer. [Troubleshoot access](https://cloud.google.com/policy-intelligence/docs/troubleshoot-access)

| Troubleshooter result | Reading |
| --- | --- |
| Not granted; no binding names the account | The role is absent. Go to check 2 to learn whether it was ever there |
| Not granted; a binding names the account with a condition that evaluates to false | A conditional grant stopped matching, such as a time limit that passed |
| Denied by a deny policy | IAM checks deny policies before allow policies, so the allow binding does not help. Read the deny policy |
| Granted | IAM is not the cause now. Look at the Admin API in both projects and the connection name |
| Unknown | You cannot read some of the policies. Ask someone who can, before concluding |

Deny policies attach to a project, folder or organization and are inherited downward. [Deny policies](https://cloud.google.com/iam/docs/deny-overview) To list those on the project:

```
gcloud iam policies list \
  --attachment-point=cloudresourcemanager.googleapis.com/projects/INSTANCE_PROJECT \
  --kind=denypolicies
```

[`gcloud iam policies list`](https://cloud.google.com/sdk/gcloud/reference/iam/policies/list) A folder or organization above the project can hold one too.

## Check 2: when did the grant change?

Every change to a project's allow policy is a `SetIamPolicy` call, written to the Admin Activity audit log, which cannot be disabled. The entry carries the caller and, in `serviceData.policyDelta.bindingDeltas`, each binding added or removed. [Resource Manager audit logging](https://cloud.google.com/resource-manager/docs/audit-logging) · [Understanding audit logs](https://cloud.google.com/logging/docs/audit/understanding-audit-logs)

```
gcloud logging read \
  'logName="projects/INSTANCE_PROJECT/logs/cloudaudit.googleapis.com%2Factivity"
   AND protoPayload.methodName:"SetIamPolicy"
   AND timestamp>="START_TIME"' \
  --project INSTANCE_PROJECT --order=asc \
  --format='yaml(timestamp, protoPayload.authenticationInfo.principalEmail, protoPayload.serviceData.policyDelta.bindingDeltas)'
```

Then read the bindings as they stand:

```
gcloud projects get-iam-policy INSTANCE_PROJECT \
  --flatten='bindings[].members' \
  --filter='bindings.members:SERVICE_ACCOUNT' \
  --format='table(bindings.role, bindings.condition.title, bindings.condition.expression)'
```

[`gcloud projects get-iam-policy`](https://cloud.google.com/sdk/gcloud/reference/projects/get-iam-policy)

| Audit log in the window | Reading |
| --- | --- |
| A `REMOVE` of `roles/cloudsql.client` for the account | Removed. The caller tells you which process: a person, or an automation account that applies infrastructure code which writes a role's whole member list |
| No change, and the binding has a condition with `request.time` | The condition expired. Conditions can grant temporary access by date and time. [IAM conditions](https://cloud.google.com/iam/docs/conditions-overview) |
| No change, no binding, no deny policy | The role was never granted on this project. Something else gave access before, such as a different identity or an instance in a different project |

## A worked fixture: removed, or expired

The fixture is illustrative. The fictional service `orders-api` in `europe-west1` runs as `orders-runtime@shop-prod.iam.gserviceaccount.com` in every revision and connects to `shop-prod:europe-west1:orders-db` through the built-in socket. From 09:01 UTC, new instances fail with `403 notAuthorized`. No deploy happened today.

Outcome A: removed by an apply.

| Time (UTC) | Source | Entry |
| --- | --- | --- |
| 08:58:14 | Admin Activity, `SetIamPolicy` by `infra-apply@shop-prod.iam.gserviceaccount.com` | `bindingDeltas`: `REMOVE` `roles/cloudsql.client` `serviceAccount:orders-runtime@...`; `ADD` `roles/cloudsql.client` `serviceAccount:reports@...` |
| 09:01:40 | `orders-api-00017` | `403 notAuthorized` |

An infrastructure change set the role's members to the reports account alone, removing the runtime account. Instances started before 08:58 hold their connections; new ones fail. Restoring the grant is an IAM change that adds the role back to `orders-runtime`; fix the infrastructure code in the same change, or the next apply removes it again.

**Outcome B: a condition expired.** The audit log shows no `SetIamPolicy` today. `get-iam-policy` lists `roles/cloudsql.client` for `orders-runtime` with the condition title `temp-migration` and expression `request.time < timestamp('2026-11-23T09:00:00Z')`. Policy Troubleshooter with `--request-time=2026-11-23T09:01:40Z` reports the condition false. The grant was written as temporary, during a migration, and never made permanent. A permanent, unconditional grant is the fix, made as an IAM change by whoever owns the project's policy.

## Where the checks mislead

`gcloud projects get-iam-policy` shows only the project's own policy. A grant inherited from a folder or the organization does not appear there; Policy Troubleshooter evaluates the effective policy, so trust it over the listing.

The 403 can also come from a misspelled connection name, since the account has no permission on an instance that does not exist under that name. If Policy Troubleshooter says granted, compare the connection name in the revision with `gcloud sql instances describe INSTANCE --format='value(connectionName)'`. [Auth Proxy troubleshooting](https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#troubleshooting)

Instances that connected before the change can keep working for a while, so a partial outage starting at a scale-out is consistent with a removed role. One healthy instance does not show that the grant exists.

## Questions

### Which role does a Cloud Run service account need to connect to Cloud SQL?

Cloud SQL Client (`roles/cloudsql.client`), granted in the project that holds the instance. It contains `cloudsql.instances.connect`, which the Cloud SQL Auth Proxy and the language connectors need.

### How do I find who removed a role from a service account?

Read the project's Admin Activity audit log for `SetIamPolicy` entries in the window. Each entry names the caller and lists the bindings it added and removed.

### Why does Cloud Run get 403 from Cloud SQL when the role is granted?

Policy Troubleshooter can show a deny policy or a condition that blocks the grant. If it reports the permission as granted, check the connection name and whether the Cloud SQL Admin API is enabled.

## 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

-   ### [A deploy changed the Cloud Run revision's service account](/learn/cloud-run-revision-service-account-changed/)
    
    Permission errors The Proofline team November 23, 2026 6 min read
    
-   ### [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
