0
votes

I have a Google App Engine app written in Node.js which connects to a Cloud SQL Postgres instance under the same GCP project. Previously I was using the standard environment and it worked fine, but when I switch to a flex environment, the SQL connection no longer works.

My app.yaml:

runtime: nodejs

env: flex

manual_scaling:
  instances: 1

beta_settings:
  cloud_sql_instances: mopho-217900:us-central1:mopho

I'm connecting to the DB through Knex with hostname /cloudsql/mopho-217900:us-central1:mopho. This gives me the following error:

Error: connect ENOENT /cloudsql/mopho-217900:us-central1:mopho/.s.PGSQL.5432

The username/password/database I'm providing are all valid, and continue to work if I switch back to the standard environment. It only fails when I switch to the flexible environment.

1
I don't have personal experience with this but you might check out the nodejs sample app.yaml at Github - github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/…afed

1 Answers

2
votes

It turns out that the Cloud SQL Admin API needed to be enabled. (thanks to this Google groups post for the pointer)