Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the hostname for a Google Cloud PostgreSQL instance?

I'm trying to connect to a PostgreSQL database on Google Cloud using SQLAlchemy. Making a connection to the database requires specifying a database URL of the form: dialect+driver://username:password@host:port/database

I know what the dialect + driver is (postgresql), I know my username and password, and I know the database name. But I don't know how to find the host and port on the Google Cloud console. I've tried using the instance connection name, but that doesn't seem to work. Anyone know where I can find this info on Google Cloud?

like image 514
matt_js Avatar asked Oct 24 '25 00:10

matt_js


2 Answers

  • Hostname: Please use instance's IP address. There is "IPv4 address" field on the instance overview page in the Cloud Console, e.g. https://console.cloud.google.com/sql/instances/[Instance Name]/overview
  • Port: we use default PostgreSQL port, 5432. I think it is possible to just omit it from the connection string.

Please also see "Connecting psql Client Using IP Addresses" page in our docs.

like image 100
rvs Avatar answered Oct 25 '25 14:10

rvs


Hostname is the Public IP address.

like image 38
Spankied Avatar answered Oct 25 '25 14:10

Spankied