0

I am having problems connecting a GCP Compute Engine VM to a Cloud SQL instance configured with private IP (no public) via Cloud SQL Auth Proxy.

After executing

$ ./cloud_sql_proxy -instances=INSTANCE_CONN_NAME=tcp:3306

I see the following output:

2021/10/11 12:29:24 Rlimits for file descriptors set to {Current = 8500, Max = 1048576}

2021/10/11 12:29:28 Listening on 127.0.0.1:3306 for *CLOUD-SQL-CONNECTION-NAME*

2021/10/11 12:29:28 Ready for new connections

2021/10/11 12:29:28 Generated RSA key in 101.010024ms

I haven't seen the final statement on the above on any of the tutorials I have read on this subject.

I CTRL-C out of the above, and I am shown:

^C2021/10/11 12:29:39 Received TERM signal. Waiting up to 0s before terminating.

I then run the below command to connect to my Cloud SQL instance:

mysql -u root -p --host 127.0.0.1

which returns:

Enter password: (password entered)

that returns once the password entered:

ERROR 2005 (HY000): Unknown MySQL server host 'CLOUD-SQL-PROXY-IP-ADDRESS:3306' (22)

Here are some additional information:

  • My VM (Ubuntu) is in the same region as my Cloud SQL instance, and in the same VPC network.
  • My CLoud SQL Admin API is enabled
  • The Cloud SQL instance is configured with only Private IP (Not public)
  • I have installed the MySQL client in my VM
  • The scope of the Cloud Access API's on my VM includes Cloud SQL (full access to all API's)
  • Both myself and the VM's service account has Cloud SQL Admin permissions
11
  • Since you are hiding addresses, it is hard to know exactly what the commands are. Try this command: mysql -u root -p --host localhost Commented Oct 11, 2021 at 16:21
  • Can you only display the first digits of your IP address? Commented Oct 11, 2021 at 18:27
  • What do the CLOUD-SQL-PROXY-IP-ADDRESS refers to in your installation? Commented Oct 12, 2021 at 9:43
  • Why are you stopping the proxy? Are you trying to start it in a background process? By the way, the message about generating an RSA key is a recent change, so older tutorials probably won't include it. Commented Oct 12, 2021 at 15:31
  • @JohnHanley thanks for the suggestion, however that didn't work. The IP address I referenced with CLOUD-SQL-PROXY-IP-ADDRESS was the Cloud Proxy IP address returned after entering the following command ./cloud_sql_proxy -instances=INSTANCE_CONN_NAME=tcp:3306 Commented Oct 12, 2021 at 17:01

1 Answer 1

0

From docs:

The Cloud SQL Auth proxy does not provide a new connectivity path; it relies on existing IP connectivity. To connect to a Cloud SQL instance using private IP, the Cloud SQL Auth proxy must be on a resource with access to the same VPC network as the instance.

Which means you won't be able to access the instance unless you are in the same VPC so either you need a vm, a tunnel or a public IP.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.