I have a dockerized django application which I've built, uploaded to GCR and then deployed as a google cloud run service. However, when starting up I get the following error (from the cloud run logs):
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/cloudsql/kingdoms-289503:us-west1:kingdomsdb/.s.PGSQL.5432"?
My database settings for django look something like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': "/cloudsql/kingdoms-289503:us-west1:kingdomsdb",
'USER': "postgres",
'PASSWORD': "password",
'NAME': "postgres",
}
}
And I've made sure to create the connection to the database
From what I understand, cloud run is supposed to magically mount a at /cloudsql that django can use to connect to postgres, but the error implies that it's not being mounted.
Is there an extra piece of configuration I would need to check to make sure that socket is there? Are there alternatives to connecting to cloudsql that don't involve this socket?
