Search code examples
mysqlgoogle-cloud-platformgoogle-cloud-sql

How to connect to Cloud MySQL from a local machine with a private IP?


I have a Cloud SQL instance setup in GCP with a private IP.

I can connect to it from within my VPC with no issues.

I'm trying to establish a connection from my local machine via VPN. The VPN can access private ranges within my VPC no issues.

I've setup the Cloud Auth Proxy, but I haven't successfully been able to connect to the Cloud SQL instance via the Cloud Proxy VM. I can connect to the MySQL instance from the VM. I don't think it's a Firewall issue, as I've opened the ports I'm connecting on, as well as 3307 and 3306 (as mentioned in the docs: https://cloud.google.com/sql/docs/mysql/connect-auth-proxy)

What am I missing here? Is the intention of using the Cloud Auth Proxy correct?

Thank you!


Solution

  • Have you configured SQL instance with authorized network that allows the ingress traffic from IP range of your VPN network? You may also find this article useful.

    Another option to connect to private Cloud SQL instance is to leverage IAP. With IAP, you don't need to use VPN to tunnel. More details can be found from this article that discusses various ways to connect to private instances.