I am trying to deploy a Nodejs app on Google Cloud Run
which is supposed to connect to the Cloud SQL
MySQL database using Sequelize
ORM.
It works fine if I use the local proxy for the cloud sql instance, but when I try to deploy it to Cloud Run, Sequelize is not able to find the db instance.
I tried giving '/cloudsql/' in the host property of sequelize, tried the public IP (it times out every time)
This is what my config looks like:
exports.PRODUCTION = {
HOST: "/cloudsql/<connection-name-here>",
USER: "<db-user",
PASSWORD: "<db-password>",
DB: "<db-name>",
dialect: "mysql",
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
};
What am I missing here?
Thanks in advance.
I figured out my mistake. I was passing the UNIX socket path in the host property (facepalm)
You have to pass the socket path in the socketPath property in dialectOptions in the config.