I am unable to connect to Google Cloud SQL Server despite Compute Instance and Cloud SQL being on same subnet (default) and the IP address being correct.

I tell Compute Instance to connect to 10.69.240.X and get the following error:

[ERR] dial tcp 10.69.240.X:5432: connect: connection timed out

This is odd because we the server is on the same subnet and Compute Instance can successfully connect to other Compute Instances using Private IP.

Any help is appreciated. The Compute Instance is also whitelisted from Cloud SQL.


There is no such thing, a Google Cloud SQL instance being part of the same VPC/Subnet as a Compute Engine instance isn't possible. Cloud SQL is a managed service, which means that Google owns the instance and the network it's connected to. As such it cannot be in one of your project's networks.

Also, Adding an address to the authorized network in Cloud SQL will only work for Public IP connectivity, Private IP is a different story.

In fact as explained here, if you need private connectivity, Cloud SQL will create a network peering between the SQL instance and the Compute Engine network(VPC) of your choice. This means that only the instances in that specific network will be able to reach Cloud SQL.

I would suggest going to the Cloud-SQL details page under 'Connections' tab, and check in-there which network you have associated (Right below 'Associated networking'). Then you just need to make sure that your client machine is part of that particular network(VPC). Also important your client subnet needs to be on the same region as your Cloud SQL instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.