3

I followed all the steps mentioned in this sample app link. GitHubLink. When running the script (npm run init-cloudsql) to initialize mysql database, I get an error below:

D:\gcloud\nodejs-getting-started\2-structured-data\books\model-cloudsql.js:143
    throw err;
    ^
Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
--------------------
at Protocol._enqueue (D:\gcloud\nodejs-getting-started\2-structured- data\node_modules\mysql\lib\protocol\Protocol.js:145:48)                                                                                                          
at Protocol.handshake (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\protocol\Protocol.js:52:23)                                                                                                                
at Connection.connect (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\Connection.js:130:18)                                                                                                                
at Connection._implyConnect (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\Connection.js:461:10)                                                                                                                
at Connection.query (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\Connection.js:206:8)                                                                                                               
at createSchema (D:\gcloud\nodejs-getting-started\2-structured-data\books\model-cloudsql.js:126:14)                                                                                                              
at prompt.get (D:\gcloud\nodejs-getting-started\2-structured-data\books\model-cloudsql.js:117:5)                                                                                                              
at D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\prompt\lib\prompt.js:336:32                                                                                                            
at D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\utile\node_modules\async\lib\async.js:154:25                                                                                                            
at assembler (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\prompt\lib\prompt.js:333:9)  

What am i missing? I could not resolve this error. Can someone help me fix this issue?

Mohit Maharjan
  • 79
  • 1
  • 3
  • 10
  • 1
    The error indicates the Cloud SQL proxy is not running correctly on your instance. Please share the output from `./cloud_sql_proxy -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306` to help us figure out why. Maybe also try it with `-verbose` added to gather more info. – David Oct 09 '17 at 04:41
  • After fixing the issue:>> D:\>cloud_sql_proxy.exe -instances="gmailenhancer-182114:asia-east1:gmail-enhancer"=tcp:3306 2017/10/09 12:02:10 Listening on 127.0.0.1:3306 for gmailenhancer-182114:asia-east1:gmail-enhancer 2017/10/09 12:02:10 Ready for new connections – Mohit Maharjan Oct 09 '17 at 06:52
  • 1
    However, I got an error below when connecting to the cloud sql database ->> '2017/10/09 12:35:07 Throttling refreshCfg(gmailenhancer-182114:asia-east1:gmail-enhancer): it was only called 21.0262008s ago 2017/10/09 12:35:07 couldn't connect to "gmailenhancer-182114:asia-east1:gmail-enhancer": dial tcp 35.194.177.25:3307: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.' – Mohit Maharjan Oct 09 '17 at 06:56

3 Answers3

4

This error occurs when you run an instance of PopSQL or Node.js and the MySQL server is not running on your local machine. Try the below steps

  1. Press Windows key and R on your keyboard. This opens the command prompt
  2. Type in services.msc and click ok.
  3. In the services pop up , check for MYSQL57. If its not in the running state, Click on run this service in the left column of the dialog box
  4. Once the service is running connect to the POPSQL from the connections window
  • This solved my issue. Thanks! Also change your startup setting to Automatic. I set it Manual while installing now it's automatic and no problem is occurring for me. – Ayush Aryan Jul 31 '21 at 08:45
1

The error message you shared indicates your machine could not connect to the instance's IP address on port 3307 (which is used by the proxy). I tested this on my own machine, and it is listening there. This likely indicates a firewall on your machine or your local network that is preventing outbound connections on port 3307. Try and open this in the firewall, and see if you can connect.

David
  • 9,288
  • 1
  • 20
  • 52
-2

You need to whitelist your IP to access Cloud SQL. https://cloud.google.com/sql/docs/mysql/instance-access-control

Yuri Grinshteyn
  • 727
  • 3
  • 13
  • Thank you for the comment but i am trying to use Cloud SQL Proxy to connect to cloud sql which do not require to white list address. – Mohit Maharjan Oct 09 '17 at 09:49