I am trying to connect to my database from my Nodejs server like this:
const db = new Sequelize(sql.database, sql.username, sql.password, sql.config); const connectDB = async () => { try { await db.authenticate(); logger.info(`MySQL DB Connected: ${sql.config.host}`) } catch (error) { logger.error(`Error: ${error}`); process.exit(1) } } My configuration looks like:
const sql = { database: process.env.SQL_DATABASE as string, username: process.env.SQL_USER as string, password: process.env.SQL_PASSWORD, config: { dialect: "mysql" as Dialect, host: "/cloudsql/{instance}" as string, dialectOptions: { socketPath: "/cloudsql/{instance}", }, }, }; However I am getting a sequelizeconnectionerror: connect ENOENT
Is there anything I'm missing to connect to my Cloud SQL instance in GCP?
{instance}value? Additionally, where is your code running? App Engine Standard, Flexible, Cloud Functions?