0
votes

I'm trying to use Cloud SQL Proxy for my Kubernetes project.

I follow the guide of Elixir and Phoenix. Under Connect to your Cloud SQL instance, that guide says that running cloud_sql_proxy -dir=/tmp/cloudsql and psql -h /tmp/cloudsql/[CONNECTION-NAME] -U postgres will open the proxy.

So I tried to make a new directory with these commands below.

mkdir -p /tmp/cloudsql
chmod +x /tmp/cloudsql

and then I tried to connect to Cloud SQL Proxy.

cloud_sql_proxy -dir=/tmp/cloudsql/                16:47
2020/10/30 16:47:50 Rlimits for file descriptors set to {&{xxxx xxxxxxxxxxxxxxxxxxx}}
2020/10/30 16:47:51 Using gcloud's active project: [instance-id]
2020/10/30 16:47:54 Listening on /tmp/cloudsql/instance-id:region:instance-name for instance-id:region:instance-name
2020/10/30 16:47:54 Ready for new connections

To connect the proxy, I opened another terminal and entered this psql command but failed.

psql -U postgres -h /tmp/cloudsql/instance-id:region:instance-name
psql: error: could not connect to server: could not connect to server: Not a directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/cloudsql/instance-id:region:instance-name/.s.PGSQL.5432"?

What should I do additionally for connecting to the proxy?

1

1 Answers

2
votes

from what I see you are passing a wrong connection name

wrong --> instance-id:region:instance-name

correct --> PROJECT_ID:region:instance-name

You can find the connection name from the

console --> Cloud SQL --> INSTANCE --> Connect to this instance --> Connection name