Cloud SQL Connection from Cloud Run in local emulator (Cloud Code) | C2C Community

Cloud SQL Connection from Cloud Run in local emulator (Cloud Code)

  • 14 October 2022
  • 2 replies

Userlevel 1
Badge +2

I am developing a Cloud Run application locally (using Cloud Code in VS Code). 


When I go to deploy the application, there is an option to set a connection my Cloud SQL instance:

However, I am not sure how to establish this connection when I am running/debugging locally as this dialog window never appears. Because of this, I am unable to access my Cloud SQL instance.


What is the correct way of running a Cloud Run application locally in Cloud Code and having a connection to my Cloud SQL Connection?


Best answer by malamin 14 October 2022, 23:04

View original

2 replies

Userlevel 7
Badge +35

Hi @davidressler 

Thank you for the question. This use case can be divided into two parts. The first part of cloud run configuration with cloud SQL and cloud code configuration with your vs code.

The second part of the database connection string should be called into your app code and it is based on your selected programming language.

The following are the configuration details for a cloud-run SQL instance.

Hopefully, you have successfully configured cloud code Extention with vscode on your local machine.

Then, configure the cloud SQL instance, enable Cloud SQL Admin API, IAM roles, and service account to use either a public or private IP address.

It would be better to follow the below link rather than write the code here step by step.

I hope it will help you to overcome the issue.




Userlevel 7
Badge +29

Hello @davidressler and welcome to C2C, the Google Cloud Customer Community! It’s great to have you with us!

First things first, did @malamin’s answer perhaps help you? Or do you need more help?

Also: Don’t forget to check out our upcoming events!

Again, a big welcome!