I have connected my node app to my Cloud SQL database and it is working perfectly locally, but when I deploy my node app to App Engine, the API no longer works. In the logs I can see the following:
(node:11) UnhandledPromiseRejectionWarning: SequelizeConnectionError: connect ETIMEDOUT
This does not happen when I run the app locally despite being connected to the same Google Cloud SQL DB.
I thought maybe it would not connect because of security restrictions, but on the SQL connections page it says the following:
Apps in this project: All authorized.
My node app is deployed within the same project, so that shouldn't be the problem.I have also whitelisted my home IP so that I could connect locally, and that was a success as mentioned before. Any help would be appreciated.
EDIT:
Here is my attempt to connect to the DB. It now fails locally & when I deploy. It works locally if I pass in the public IP to the "host."
const sequelize = new Sequelize('linkspot', 'kyle', 'password', {
host: '/cloudsql/linkspot:us-central1:linkspot-mysql',
dialect: 'mysql',
port: 3306,
pool: {
max: 5,
min: 1,
acquire: 30000,
idle: 10000
}
});