postgresqlgoogle-cloud-platformconnection-string

GCP hostname resolving error (no such host)


I have been working with Google Cloud Run and PostgreSQL for some years.

Now I am trying to set up a new web application for hours, created the postgres instance, set the password to the user postgres, added a cloud run using "Continuously deploy from a repository" through Dockerfile. It builds with no errors, but in the log I find the following error:

failed to connect to `host=fleet-XXXX-r5:europe-west8:my-project user=postgres database=staging`: hostname resolving error (lookup fleet-XXXX-r5:europe-west8:my-project: no such host)

I suppose the connection string is wrong but don't understand what:

postgresql:///postgres?host=fleet-XXXX-r5:europe-west8:my-project&database=staging&user=postgres&password=myPassword&sslmode=disable

Any hint?


Solution

  • Alfter houers of strugggeling I found the problem, I was missing the cloudsql prefix:

    postgresql:///postgres?host=/cloudsql/fleet-XXXX-r5:europe-west8:my-project&database=staging&user=postgres&password=myPassword&sslmode=disable