Unable to connect to Google cloudsql instance

475 views Asked by At

An ENOENT error occurs on repeat when running a Google Nodejs app configured to use a second generation MYSQL instance with the appropriate instance name. This works on my localhost using the cloudproxy, but produces the following error in a compute cluster instance. A similar error occurs with an app engine deploy.

error when connecting to db: { Error: connect ENOENT cybers-cafe:us-east1:cybers-cafe
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
    --------------------
    at Protocol._enqueue (/home/jordocote/cybers-cafe-service/node_modules/mysql/lib/protocol/P
    at Protocol.handshake (/home/jordocote/cybers-cafe-service/node_modules/mysql/lib/protocol/
    at Connection.connect (/home/jordocote/cybers-cafe-service/node_modules/mysql/lib/Connectio
    at Timeout.handleDisconnect [as _onTimeout] (/home/jordocote/cybers-cafe-service/entities/r
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'connect',
  address: 'cybers-cafe:us-east1:cybers-cafe',
  fatal: true }

I have tried using various socketPath values:

  • cybers-cafe:us-east1:cybers-cafe,
  • /cloudsql/cybers-cafe:us-east1:cybers-cafe,
  • IP address of MYSQL instance (with and w/o port),
  • just 3306

They all produce the same error in a compute cluster instance and in an app engine deploy. I was also unable to connect to the MYSQL instance directly using mysql client from the compute cluster instance.

I have followed the setup procedure in docs such as https://cloud.google.com/sql/docs/mysql/connect-app-engine and looks like this:

env_variables:
  MYSQL_USER: ******
  MYSQL_PASSWORD: ***********
  MYSQL_DATABASE: cyberscafe
  # This path was printed to the console when you started the proxy, and is of
  # the format: `/[DIR]/[YOUR_PROJECT_ID]:[YOUR_REGION]:[YOUR_INSTANCE_NAME]`
  MYSQL_SOCKET_PATH: cybers-cafe:us-east1:cybers-cafe
beta_settings:
  # The connection name of your instance on its Overview page in the Google
  # Cloud Platform Console, or use `[YOUR_PROJECT_ID]:[YOUR_REGION]:[YOUR_INSTANCE_NAME]`
  cloud_sql_instances: cybers-cafe:us-east1:cybers-cafe
0

There are 0 answers