0
votes

When I try to connect second generation Cloud mysql with app engine using sequilize it give me following Error:

{"name":"SequelizeConnectionError","parent":{"errno":"ENOENT","code":"ENOENT","syscall":"connect","address":"/cloudsql/phrasal-charger-215107:asia-south1:newdish123","fatal":true},"original":{"errno":"ENOENT","code":"ENOENT","syscall":"connect","address":"/cloudsql/phrasal-charger-215107:asia-south1:newdish123","fatal":true}}

Sequelize option set:-

const db = new Sequelize(
  config.database.db,
  config.database.username,
  config.database.password,
  {
    host:'localhost',
    dialect: "mysql",
    port: 3306,
    dialectOptions: {
        socketPath: '/cloudsql/phrasal-charger-215107:asia-south1:newdish123'
    }
  }
);

app.yaml

runtime: nodejs
env: flex


beta_settings:
  cloud_sql_instances: phrasal-charger-215107:asia-south1:newdish123

MORE INFO

I tried putting '/cloudsql/phrasal-charger-215107:asia-south1:newdish123' in host didn't work.

when I put public ip address in the host given by CloudSQL and setting my ip with GCP as authorised ip then the sequelize is running perfectly and performing operation as expected.

2
I'm getting the same problem using the mysql node library, so I think it's got more to do with the proxy. I believe ENOENT means the /cloudsql/ directory is missing. - Jim Jimson

2 Answers

1
votes

Manually add the IP addresses of machines/networks that need access to Cloud SQL to the Authorized Networks section.

And

Check your proxy while making connection

1
votes

I was getting the exact same issue, all of my code base didn't change at all. What I did to fix it was to create a new project and then create new App Engine Instance and a new Cloud SQL database in my new project.

Then I enabled SQL Admin for the project, created a new profile by running

gcloud init

and creating a new profile for the new project.

Then I deployed the app again:

gcloud app deploy

You can find the setup of my project here:

Node.JS on Google App Enging with Cloud SQLError: connect ENOENT /cloudsql/