I have a problem to connect on my CloudSQL Postgres instance with a psql client. I followed the documentation https://cloud.google.com/sql/docs/postgres/connect-admin-proxy.
I have enable the Cloud SQL Admin API & installed the cloud_sql_proxy :
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy
I use my credential SDK Cloud who have all the rights and i have set the good project :
gcloud config set project gta-staging-280808
Next, i have launch the following comandes :
To test with TCP sockets :
./cloud_sql_proxy -instances=gta-staging-280808:europe-west1:${INSTANCE_ID}=tcp:5432
psql "host=127.0.0.1 sslmode=disable dbname=${DB_NAME} user=${USER}"
To test with Unix sockets :
./cloud_sql_proxy -dir=/cloudsql &
psql "sslmode=disable host=/cloudsql/gta-staging-280808:europe-west1:${INSTANCE_ID} user={USER}"
Result:
2020/08/27 15:36:39 New connection for "gta-staging-280808:europe-west1:${INSTANCE_ID}"
2020/08/27 15:40:59 couldn't connect to "gta-staging-280808:europe-west1:${INSTANCE_ID}": dial tcp XX.XX.XX.XX:3307: connect: connection timed out
There is no SSH. The VPC is the default.
Why it's doesn't work? Do you have any idea?
psql
(are you using the external IP, what port are you using) – Neo Anderson