Cannot connect from cli

2,065 views
Skip to first unread message

Alessandro Tagliapietra

unread,
Jan 14, 2018, 12:59:57 AM1/14/18
to Google Cloud SQL discuss
I've been trying to connect using cli since a while without success and I'm finally trying to solve this issue instead of relying on the cloud console.

When I try to connect to our DB using `gcloud sql connect app-production --user postgres` cli throws this error:

ERROR: (gcloud.sql.connect) HTTPError 400: Invalid instance property.

if I try other things like `gcloud sql databases list -i app-production` everything works fine.
The IAM account I'm using has Editor permission so should include cloudsql.instances.connect.

Any idea?

nau...@google.com

unread,
Jan 14, 2018, 1:02:04 PM1/14/18
to Google Cloud SQL discuss
Hello Alessandro, 

In order to troubleshoot this problem, please open a private issue report using this link [1] and provide the output with the "--log-http" flag which will provide detailed information of underlying request and responses. 

Example: gcloud sql connect <instance-name> --user <user-name> --log-http

Note: Please remove contents of the Authorization header included in the debug output, since this contains a bearer token.

In addition, provide details on if you are able to connect to the Cloud SQL instance using the IP address[2], Cloud SQL proxy[3]?

[1] https://issuetracker.google.com/issues/new?component=187164
[2] https://cloud.google.com/sql/docs/mysql/connect-admin-ip

Pia Chamberlain

unread,
Jan 16, 2018, 12:40:05 PM1/16/18
to Google Cloud SQL discuss
A couple of things to check-- when you say your IAM account has Editor permission, is that the legacy Project > Editor permission, or the Cloud SQL Editor permission? The former does indeed include the cloudsql.instances.connect permission, but the latter does not. Also, your instance must have an IPv4 address for this command to work.

Alessandro Tagliapietra

unread,
Jan 16, 2018, 12:47:16 PM1/16/18
to Google Cloud SQL discuss
The IAM user has Project > Editor permissions (legacy?), if I remove that the error changes to forbidden. Instance has IPV4 address, if I whitelist my ip I can connect using regular postgresql tools.

nau...@google.com

unread,
Jan 21, 2018, 5:07:37 PM1/21/18
to Google Cloud SQL discuss
For the community visibility, currently Cloud SQL 2nd gen instances do not whitelist IPv6 (public) address associated with the client when using: 'gcloud sql connect'. There is a feature request submitted to support this. 
Reply all
Reply to author
Forward
0 new messages