Home > Enterprise >  App Engine Standard connect to Cloud SQL in prisma and nest.js
App Engine Standard connect to Cloud SQL in prisma and nest.js

Time:03-15

I'm trying to deploy a nestjs with prisma to an App Engine Standard service and using Cloud SQL mysql, but I couldn't make the connection work with the socket.

I can whitelist my local IP and connect to CloudSQL, but when it is deployed it doesn't work.

  • Cloud SQL Admin Api is enabled.
  • They are in the same project.
  • When I run cloud sql proxy in my local machine, it works.
  • I have tried to follow prisma guide on how it works with mysql socket, but it didn't work.

There is a guide on creating a serverless VPC, but it will increase costs and I can't just accept that I can connect from my local to cloud sql, but there isn't a way to connect services in the same zone and same project.

Is there some known way of making this work?

CodePudding user response:

I could finally connect the App Engine Standard with Cloud SQL.

Of course, all of the things I said I did on the question it was necessary, but this stackoverflow answer that solved my problem (https://stackoverflow.com/a/42493299/3512694), on App Engine environment the Cloud SQL proxy works on port 3307 and not in port 3306 that is the MySQL default port.

My config worked using this env var for prisma: MYSQL_URL: mysql://:@localhost:3307/<db_name>?socket=/cloudsql/<instance_connection>

  • Related