9
votes

This is the error that comes up when I try to use Cloud SQL Proxy to configure access to Google Cloud SQL in windows - "listen tcp 127.0.0.1:3306: bind: An attempt was made to access a socket in a way forbidden by its access permissions."

This is the format of the command I'm using "cloud_sql_proxy.exe -dir=/cloudsql -instances=my-project:us-central1:sql-instance=tcp:3306 mysql -u --host " - as is described in the docs.

Can someone please let me know what's actually causing this ?

4

4 Answers

20
votes

The SQL Server engages the 3306 port locally. Therefore you cannot bind to it while it's running. Stop the SQL Server to bind the CloudSQL Proxy to it.

Incase of Windows 10: Go to Task Manager -> Services -> MySQL57

Right click and stop that task. Once you have done that try running the same command again. It'll work and show as output

Listening on 127.0.0.1:3306 for <instance-name>
15
votes

It sounds like another process is already using 3306. Can you try specifying a different port? e.g. -instances=my-project:us-central1:sql-instance=tcp:3307

1
votes

As per the google docs use this command on windows cmd or google sdk shell cloud_sql_proxy.cmd -instances=<INSTANCE_CONNECTION_NAME>=tcp:3306 -credential_file=<PATH_TO_KEY_FILE> (make sure to declare cloud_sql_proxy.cmd as environment variable)where in your case

  • INSTANCE_CONNECTION_NAME = my-project:us-central1:sql-instance
  • PATH_TO_KEY_FILE = create a service account in IAM panel and save the json file copy its path and paste it here.

if this doesnt work try connecting tcp to 3307 as mentioned in above post.

0
votes

I my case I was using docker image with the same port installed in my local machine so the local mysql is not allowing to access the port because is already been used and running. I Uninstall local mysql .now its working fine