Learning center

The Cloud SQL Admin API is disabled for a Cloud Run connection

When Cloud Run's Cloud SQL connection reports Error 403: Access Not Configured, check that sqladmin.googleapis.com is enabled in each project involved. That is the project the service connects from, and the instance's project if it is a different one. The Service Usage audit log says who disabled it and when. Services that connect by TCP to the private IP keep working, because no proxy or connector on their path calls the API.

Why the API is on the path#

The Cloud SQL Auth Proxy, which Cloud Run embeds for its built-in connection, calls the Cloud SQL Admin API to obtain an ephemeral certificate before it connects, and the Admin API must be enabled to use it. The language connectors call the same API through sqladmin.googleapis.com. About the Auth Proxy · Auth Proxy requirements

Cloud SQL's Cloud Run guide asks for the API in the project you connect from. When the service account belongs to a different project than the instance, it must be enabled in both. Connect from Cloud Run · Public IP setup

The Auth Proxy troubleshooting guide prints the symptom: with the API disabled, the proxy logs show output like Error 403: Access Not Configured. Auth Proxy troubleshooting That is a refusal at stage 2 of the four stages, next to a missing Cloud SQL Client role, which returns 403 notAuthorized instead. The service account lacks Cloud SQL Client

The direct private IP path uses TCP to the instance without the Auth Proxy. Connect with TCP Nothing on that path calls the Admin API to connect, so a disabled API leaves it working. A language connector set to the private IP type still calls the API.

Check 1: which projects need it?#

Two projects can matter: the project that holds the Cloud Run service, and the project that holds the instance, the first part of the connection name PROJECT:REGION:INSTANCE.

gcloud run revisions describe REVISION --project PROJECT --region REGION \
  --format='yaml(metadata.annotations, spec.serviceAccountName)'

The run.googleapis.com/cloudsql-instances annotation gives the connection names, and the service account's email shows its home project. Revision template annotations When the instance or the account is elsewhere, see an instance in another project for the other settings that go with it.

Check 2: is it enabled now?#

for p in SERVICE_PROJECT INSTANCE_PROJECT; do
  echo "== $p"
  gcloud services list --enabled --project "$p" | grep sqladmin.googleapis.com
done

gcloud services list --enabled lists the services a project has enabled. gcloud services list An empty result under a project means the API is not enabled there.

Service projectInstance projectReading
EnabledEnabledThe API is not the cause. Read the role, the connection name and the quota
DisabledAnyThe proxy in the service's project cannot call the API. Find when it was disabled
EnabledDisabled, and the projects differThe cross-project requirement is not met. Find when it was disabled

Enabling the API is a change to the project: gcloud services enable sqladmin.googleapis.com --project PROJECT. It needs serviceusage.services.enable, for example through the Service Usage Admin role. Enable the API

Check 3: who disabled it, and when?#

Enabling and disabling services are Admin Activity audit events from Service Usage, with the methods google.api.serviceusage.v1.ServiceUsage.EnableService, DisableService and BatchEnableServices. Service Usage audit logging Admin Activity logs cannot be disabled. Understanding audit logs

gcloud logging read \
  'protoPayload.serviceName="serviceusage.googleapis.com"
   AND protoPayload.methodName:"DisableService"
   AND timestamp>="START_TIME"' \
  --project PROJECT --order=asc \
  --format='value(timestamp, protoPayload.authenticationInfo.principalEmail, protoPayload.resourceName)'
Audit logReading
A DisableService for sqladmin.googleapis.com in the windowDisabled then. The caller tells you which person or automation did it, and that process will do it again unless it changes
None in the window, and the API is disabledIt was never enabled in this project. Something else connected before: another project, another path or another service

Then compare the time with the first failure. Instances already running keep their proxy connections, so failures start when new instances start or when existing connections need a new certificate, which the proxy refreshes before the roughly one-hour expiry. How the Auth Proxy works

A worked fixture: which service still works#

The fixture is illustrative. In the fictional project shop-prod, orders-api connects to shop-prod:europe-west1:orders-db through the built-in socket. A second service, stock-api, connects to the same instance by TCP on its private address 10.40.0.3 through Direct VPC egress.

Outcome A: disabled by an automation.

Time (UTC)SourceEntry
08:50:12Service Usage audit logDisableService on sqladmin.googleapis.com, caller infra-apply@shop-prod.iam.gserviceaccount.com
09:12:41orders-api-00018Proxy output with Error 403: Access Not Configured
09:14:05orders-api-00017, fresh instance via tag prevSame error
09:14:30stock-apiNo database errors

stock-api is unaffected because its path does not use the API, and both revisions of orders-api fail. The 09:12 deploy only started the first new instances after the change; a rollback will not help. An infrastructure change removed the API from the project. Enabling it restores connections; fix the code that removed it too.

Outcome B: a second project. The same service moves to a new instance shop-data:europe-west1:orders-db in the project shop-data, with orders-runtime granted Cloud SQL Client there. orders-api-00018, deployed at 09:12:30 with the new connection name, fails with Error 403: Access Not Configured. sqladmin.googleapis.com is enabled in shop-prod and absent in shop-data, and no DisableService appears there: it was never enabled. The new instance's project needs the API as well.

Where the checks mislead#

A 429 with rateLimitExceeded from sqladmin.googleapis.com also comes from the Admin API, and it means a quota, not a disabled API. Cloud Run's use of the API grows with the number of instances: roughly twice the number of connected Cloud SQL instances times the number of Cloud Run instances. Auth Proxy troubleshooting · API quota limits

A service that keeps working is evidence about its own path only. stock-api working says nothing about the API; it never needed it.

Questions#

Does Cloud Run need the Cloud SQL Admin API to connect to Cloud SQL?

For the built-in Cloud SQL connection and the language connectors, yes: the Auth Proxy and the connectors call it to get certificates. A direct TCP connection to the instance's private IP does not go through them.

In which project must the Cloud SQL Admin API be enabled?

In the project you connect from. When the instance and the service account are in different projects, enable it in both.

How do I find out who disabled the Cloud SQL Admin API?

Read the project's Admin Activity audit log for Service Usage DisableService entries. Each one names the caller and the time.

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.

Start free with GitHub

Related reading