Eric Smith
Eric Smith

Reputation: 186

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?

Upvotes: 7

Views: 5728

Answers (2)

fabs
fabs

Reputation: 31

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'])

Upvotes: 3

Erick Servin
Erick Servin

Reputation: 93

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

Upvotes: 3

Related Questions