Summary of the issue
My Cloud Run service and Cloud Run job cannot connect to my Cloud SQL instance using the Cloud SQL Connector (socket path).
I’ve followed the official documentation:
Connect from Cloud Run | Cloud SQL for PostgreSQL | Google Cloud
However, both /db/ping endpoint and the migration job
fail with internal errors.
error from Cloud Run logs
Cloud SQL connection failed.
dial error: failed to dial (connection name = "
“ connection to Cloud SQL instance at ** failed: timed out after 10s
Error from Cloud Run Job logs
psql: error: connection to server on socket "
failed:
server closed the connection unexpectedly
⸻
Checks already done
• Cloud SQL instance uses Private IP only, and I can connect via psql from a VM in the same VPC →
works fine.
• enablePrivatePathForGoogleCloudServices = true
• Cloud Run service has --add-cloudsql-instances=:**me-central2:..
• DATABASE_URL secret uses: host=/cloudsql/***
• VPC connector is READY and in the same region.
• Firewall rules allow egress to 0.0.0.0/0 on TCP:443 and to SQL range on TCP:5432.
• Org Policy sql.restrictPublicIp and sql.restrictAuthorizedNetworks enforced at org level, but Private IP should not be affected.
• Tried both private-ranges-only and all-traffic egress, same result.
Could you help, please?
Thanks