Cloud SQL UNIX socket not showing up on Cloud Run - /cloudsql directory empty

Hi all, running into an issue with Cloud SQL + Cloud Run and hoping someone has seen this before.

My Cloud Run service connects to a Cloud SQL (Postgres) instance via Unix socket using asyncpg. It works perfectly over TCP locally, but in Cloud Run the /cloudsql directory is always empty at runtime - the socket file is never created.

Connection code:

socket_path = f"/cloudsql/{db_instance_connection_name}"
# e.g. /cloudsql/my-project:us-east1:my-instance

_db_pool = await asyncpg.create_pool(
    user=db_user,
    password=db_password,
    database=db_name,
    host=socket_path,
    timeout=5
)

Debug check at startup:

print(f"DEBUG: Checking for socket at: {socket_path}")
if os.path.exists('/cloudsql'):
    print(f"DEBUG: /cloudsql contents: {os.listdir('/cloudsql')}")
else:
    print("DEBUG: /cloudsql does not exist")

What I’m seeing in logs:

DEBUG: Checking for socket at: /cloudsql/my-project:us-east1:my-instance
DEBUG: /cloudsql contents: []

The directory exists, but it’s empty - so the proxy sidecar is never creating the socket.

Everything I’ve already confirmed:

  • run.googleapis.com/cloudsql-instances annotation is on spec.template.metadata.annotations (not top-level)
  • Cloud SQL instance is RUNNABLE
  • Service account has roles/cloudsql.client
  • sqladmin.googleapis.com API is enabled
  • Multiple fresh redeploys done after each change
  • TCP connection to the same instance works fine locally, so credentials and DB config are correct

At this point it seems like a proxy sidecar issue at the infrastructure level since everything on the config side checks out. Has anyone run into this or know what else could cause the socket to never be written?

Thanks

2 Likes