Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google CloudSQL, getting "connect ECONNREFUSED 127.0.0.1:3306"

I'm trying my best to learn Google's Cloud Platform. They have a CloudSQL offering, which I'm learning via this NodeJS tutorial. Everything worked great until I deployed to their appspot server, at which point I got the following error:

connect ECONNREFUSED 127.0.0.1:3306

I've looked all through the NodeJS project and don't see anything in it or the Cloud Console that is referencing localhost or 127.0.0.1. Googling the error hasn't helped thus far. Any ideas?

like image 810
Eric Smith Avatar asked Jan 12 '17 00:01

Eric Smith


People also ask

What is Google Cloud MySQL?

Cloud SQL for MySQL is a fully-managed database service that helps you set up, maintain, manage, and administer your MySQL relational databases on Google Cloud Platform. For information specific to MySQL, see the MySQL documentation or learn more about Cloud SQL for MySQL.


2 Answers

I couldn't get this thing fixed when running on server but using this files I was able to read/write from local and production, now im using this connection strings in my own app

https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/cloudsql

like image 200
Erick Servin Avatar answered Oct 22 '22 08:10

Erick Servin


I had a similar issue when deploying the nodejs sample app 2-structured-data

The reason why the error occurred is that the NODE_ENV environment variable was not passed to the config file that is used to check if node should use a socket for connecting to mysql

You can fix it by adding 'NODE_ENV' in the file config.js :

.env([
 ...
'NODE_ENV'])
like image 35
fabs Avatar answered Oct 22 '22 09:10

fabs