1
votes

I am using Google App Engine and Cloud SQL (My SQL 2nd Gen Instance) in my Node JS application and I am having troubles.

I am connecting fine in local using cloud proxy, but as soon as I deploy it fails.

I am using Sequelize to connect to cloud SQL.

I do have correct password/username/instance connection name. I have enabled API, otherwise I would not be able to connect from proxy.

In my "app.yaml" I do have correct "beta_settings" tag with correct "cloud_sql_instances" value.

Message from Cloud SQL:

`{insertId:  "s=7560d77466cb46cebc3933acc1c41082;i=1a5ff5;b=30867f100f0d483ea84a5718c3948aed;m=886b8bfcbb;t=578fd8d7ad54f;x=a821eba2c35efe29-0@a1"  
 logName:  "projects/[CORRECT PROJECT]/logs/cloudsql.googleapis.com%2Fmysql.err"  
 receiveTimestamp:  "2018-10-24T18:21:25.190291090Z"  
 resource: {
  labels: {
   database_id:  "[CORRECT DB ID]"    
   project_id:  "[CORRECT PROJECT ID]"    
   region:  "us-central"    
  }
  type:  "cloudsql_database"   
 }
 severity:  "ERROR"  
 textPayload:  "2018-10-24T18:21:19.249532Z 53509 [Note] Access denied for user 'root'@'cloudsqlproxy~66.85.23.1' (using password: NO)"  
 timestamp:  "2018-10-24T18:21:19.249743Z"  }`

Message fron APP Engine (Express, Sequelize):

`Error: connect ECONNREFUSED 127.0.0.1:3306 at TCPConnectWrap.afterConnect [as oncomplete]`

It seems like similar question has been asked numerous times, and I have read more than 10 stackoverflow questions and answers and I still do not have right answer for it.

Can I get some help?

Thank you.

1
Which articles are you referring too could not find any? - Ritesh Karwa

1 Answers

-1
votes

I know this is old - but I've been having the same problem with my NodeJS app connecting to CloudSQL Postgres. A little digging on the AppEngine instance eventually showed that while the docs show 127.0.0.1 as the host, it's actually running the CloudSQL proxy docker image - so while it's 127.0.0.1 from the instance itself, my database hostname actually needed to be "cloudsql" from the app container.

Try connecting to cloudsql:3306 and see if it works!