0

Getting below error while trying to communicate mysql database from gcloud django app deploy. Below is the error message:

OperationalError at / (2002, "Can't connect to local MySQL server through socket '/cloudsql/aevolveai-app-beta:us-central1:mysqlocr-uat1' (111)") 

Please advise how to resolve it, sorry I am new to gcloud and serverfault

4
  • Is the mysql server running on the same host as your app? If not, is it configured to allow connections from remote hosts? Commented Jan 24, 2022 at 17:52
  • Yes, i copied the connection name from gcloud sql engine. I can connect to mysql database from gcloud console by using below command gcloud sql connect mysqlocr-uat1 --user=root But I am not able to understand why I am now able to connect from my hosted application. I have made below changes in my django setting.py file. ** 'ENGINE': 'django.db.backends.mysql', 'HOST': '/cloudsql/aevolveai-app-beta:us-central1:mysqlocr-uat1', 'USER': 'root', 'PASSWORD': , 'NAME': '_ocrmysqluat1', ** Commented Jan 26, 2022 at 9:32
  • I found something, my python version it is showing as 2.7 in gcloud console. Can you please let me know how to update it. even pip is not installed and when I am trying to install it I a facing below error. Traceback (most recent call last): File "/usr/bin/pip", line 5, in <module> from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip' Commented Jan 26, 2022 at 10:42
  • I fixed this version problem but still getting the same error Commented Jan 26, 2022 at 12:34

1 Answer 1

0

you are using a Cloud SQL instance according to your comments. to connect to it you need:

  • proper service account authorization
  • proper connection between your workload and the SQL if your workload is not in a VM but is deployed into a PaaS (like cloud run) additional steps must be followed like VPC private connector setup.

btw once the 'basic' connection works, it is recommended that you you the cloud sql proxy tool to connect and authenticate into the Cloud SQL instance

1
  • Thanks for your advice..I talked to one of the gcloud support member and they fixed the issue. And yes, there was an issue on proper service account authorization so as they suggested I show add service account details in app.yml and it worked. Commented Feb 19, 2022 at 18:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.