I am a newbie trying to deploy a toy django app on the standard App engine and I am getting the following errors.
Running App locally
My app runs properly locally with the cloud SQL when I use 127.0.0.1 or Public IP as 'HOST' address. However, I get a this error if I use GCP connection name like this:
'HOST': '/cloudsql/asim800:us-central1:django-mysql-1'
OperationalError: (2002, "Can't connect to local MySQL server through socket '/cloudsql/asim800:us-central1:django-mysql-1'
Running App on GAE
Using HOST='/cloudsql/asim800:us-central1:django-mysql-1', I get this error 2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)" - not sure why I am getting 'localhost' in the error but there seems to be something wrong with translating Google connection name to host and port information.
Using public IP for mysql instance on the GAE results in timeout.
My settings.py looks like this
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/asim800:us-central1:django-mysql-1',
'NAME': 'myproject',
'USER': 'pblogsu',
'PASSWORD': '****',
}
}
I can see them correctly in the following log:
{'database': 'myproject', 'host': '/cloudsql/asim800:us-central1:django-app1', 'password': 'pblogsu', 'user': 'hidden'}
I have enabled Google Cloud SQL API. Not sure how to debug Google connection name mapping to host/port addresses. I have seen similar problem reported like here (https://github.com/GoogleCloudPlatform/python-docs-samples/issues/870) but none of the suggestions have helped me. Any help would be greatly appreciated.
PS: I have edited my question substantially. Earlier I had used postgesql with very similar results.