CodexBloom - Programming Q&A Platform

GCP Cloud SQL Connection Timeout When Using Node.js with Sequelize

👀 Views: 96 💬 Answers: 1 📅 Created: 2025-06-20
gcp cloud-sql sequelize node.js JavaScript

I just started working with I'm upgrading from an older version and I'm relatively new to this, so bear with me. I've searched everywhere and can't find a clear answer. I'm working with a connection timeout scenario when trying to connect to my Cloud SQL instance from a Node.js application using Sequelize. The connection parameters seem correct, but after a few seconds, I receive the following behavior: `ETIMEDOUT`. Here's the configuration I’m using: ```javascript const { Sequelize } = require('sequelize'); const sequelize = new Sequelize('database', 'username', 'password', { host: 'your-cloud-sql-instance-ip', dialect: 'mysql', dialectOptions: { socketPath: '/cloudsql/your-project-id:your-region:your-instance-name' } }); ``` I’ve verified that: - The Cloud SQL instance is set to allow connections from my App Engine service. - The `socketPath` is correct (it matches the instance name in the Google Cloud Console). - My IAM roles include the necessary permissions for connecting to the Cloud SQL instance. I also tried increasing the connection timeout in Sequelize like this: ```javascript const sequelize = new Sequelize('database', 'username', 'password', { host: 'your-cloud-sql-instance-ip', dialect: 'mysql', dialectOptions: { socketPath: '/cloudsql/your-project-id:your-region:your-instance-name', connectTimeout: 10000 // 10 seconds } }); ``` Despite these attempts, I still receive the timeout behavior. I've checked the networking settings and confirmed that my App Engine can reach the Cloud SQL instance. Can anyone provide insights on what might be going wrong and how to resolve this? Thanks in advance! My team is using Javascript for this REST API. Any examples would be super helpful. Thanks for taking the time to read this!