Your data center reaches Google Cloud through a transit VPC. Your Cloud SQL instance serves workloads on a Shared VPC. Here is how an application in the data center reaches the database privately, and what you configure so it can.
Swipe the map sideways to see the whole route.
The usual way to give Cloud SQL a private IP is private services access. Google runs the instance in its own producer VPC and peers that VPC to your Shared VPC. That works for workloads in the Shared VPC, but on-prem traffic would have to cross two peerings: transit to Shared VPC, then Shared VPC to Google's producer network.
The catch: VPC Network Peering isn't transitive. A packet that arrives in the transit VPC can reach the Shared VPC over peering, but it can't continue over the Shared VPC's second peering to the database. Exporting custom routes doesn't change that.
Private Service Connect sidesteps the problem. Turn it on for the instance and Cloud SQL publishes a service attachment. You then create an endpoint, a forwarding rule with an internal IP, in any VPC whose project is on the instance's allowed list. Put one endpoint in the transit VPC for on-prem traffic and one in the Shared VPC for in-cloud workloads. Both lead to the same instance, and you publish both under the instance's DNS name.
Any peering between the transit VPC and the Shared VPC can stay for other traffic. Database traffic from on-prem never uses it.
Each instance has its own service attachment, and read replicas are instances. Every instance you want to reach needs one endpoint and one DNS record in each VPC that connects to it. Each endpoint takes a single address from an ordinary subnet, so no special range is required.
Fill in your names. The commands below update as you type. They cover the primary instance; repeat the endpoint and DNS steps for each replica.
Your ticks are saved in this browser.
| What you see | Usual cause | Fix |
|---|---|---|
| Forwarding rule shows a connection status other than accepted | The endpoint's project isn't on the instance's allowed list. | Patch the instance to include both the host and transit projects, then recreate the forwarding rule. |
| Instance name doesn't resolve on-prem | No conditional forwarder, or no private zone bound to the transit VPC. | Create the zone and A record in the transit project, add an inbound server policy, and forward the Cloud SQL domain to its addresses. |
| Name resolves to the Shared VPC endpoint, then times out | On-prem is reading the Shared VPC's zone. That address is only reachable from the Shared VPC. | Point forwarding at the transit VPC so the answer is the transit endpoint IP. |
| DNS is right but the port times out | Cloud Router isn't advertising the endpoint subnet, on-prem firewalls block the port, or the hybrid link lands in another region. | Advertise the subnet, open the engine port (and 3307 for connectors), and turn on global access on the endpoint. |
| Auth Proxy or a connector fails before connecting | It can't reach the Cloud SQL Admin API from on-prem, or the identity lacks the Cloud SQL Client role. | Allow on-prem access to sqladmin.googleapis.com (internet or Private Google Access for on-premises hosts) and grant the role. |
| Primary works, replica doesn't | Replicas have their own service attachment and DNS name. | Create endpoints and DNS records for each replica in both VPCs. |