1
votes

I am new to google cloud but was just able to deploy the test Django app that google provided in their documentation. This process included downloading the cloud_sql_proxy and running the following in the terminal (MacOS):

./cloud_sql_proxy -instances="my-instance-274702:us-central1:fms"=tcp:3306

This command starts running the proxy in order to connect locally to the DB in the cloud. Everything was working fine until I terminated the proxy with ctrl + C. When I ran the following command to start the proxy again I got the following error:

ludovico@Ludovicos-MacBook-Pro django % ./cloud_sql_proxy -instances="my-instance-274702:us-central1:fms"=tcp:3306
2020/04/18 23:38:10 Rlimits for file descriptors set to {&{8500 9223372036854775807}}
2020/04/18 23:38:12 listen tcp 127.0.0.1:3306: bind: address already in use

I got this error the first time I did this but I fixed it by shutting down the MySQL server that was running on port 3306. Now however, port 3306 is already bound to the cloud_sql_proxy and so it is throwing an error and is unable to start the proxy. If I run the same command with port 3307 it works just fine:

./cloud_sql_proxy -instances="my-instance-274702:us-central1:fms"=tcp:3307

But Django does not look for port 3307 it looks for port 3306.

Is it possible to unbind port 3306? Better yet, is there a command to start running the proxy instead of binding and unbinding port 3306 each time?

1
hi do this, "ss -lptn" this will show you running process. check the process running on port 3306, then kill that process by "kill -9 {process_id}" and re run your proxy, app. It will run on 3306. then django will work fine. Do comment if this works.Rahul
@Rahulroy "ss - lptn" returns an error in the terminal: zsh: command not found: ss-lptn.Ludovico Verniani
the command is ss -lptn there is a space between ss and "-lptn" hope you are tying the command correct. It should work fine on a linux environment.Rahul
I am on Mac but I found a similar command that worked, thanksLudovico Verniani
@Rahulroy please put your first comment as answer to mark it as answer and upvote itJan Hernandez

1 Answers

3
votes

use ss -lptn the sport command to show which port is bind to which process. Then kill the process running on 3306 by kill -9 {process_id} this will unbind your busy port 3306. Then you can run process on 3306.