'Cloud Functions - PrismaClientInitializationError: Can't reach database server at `my.cloudsql.ip`:`3306

Im trying to deploy my NodeJS app to Google cloud functions connected to a Cloud SQL instance (MySQL) and using Prisma ORM.

The deployment was successful, but whenever I access an API route with a connection to the database, I get the following error as a response:

PrismaClientInitializationError: Can't reach database server at `my.cloudsql.ip`:`3306`. Please make sure your database server is running at `my.cloudsql.ip`:`3306`.

My database string looks like this: "mysql://user:password@cloud-sql-ip/database?host=/cloudsql/instance-connection-name"

I alread try adding ?connect_timeout=300 to the connection string of the database as mentioned here. But I didn't succeed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source