ERROR: (gcloud.sql.connect) HTTPError 400: The incoming request contained invalid data
Asked Answered
G

3

12

Problem

I am not able to connect to my Cloud SQL postgres instance with the command line, which has been working previously:

gcloud sql connect <instance_name> --user=<username>

This is the error I'm getting:

ERROR: (gcloud.sql.connect) HTTPError 400: The incoming request contained invalid data.

Version

Running macOS Mojave 10.14 (18A391) with a tethered 4G hotspot via my Samsung Galaxy S8.

$ gcloud --version

Google Cloud SDK 227.0.0
bq 2.0.39
core 2018.11.30
gsutil 4.34

Log

Running the command with the --log-http flag, it returns:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalidRequest",
    "message": "The incoming request contained invalid data."
   }
  ],
  "code": 400,
  "message": "The incoming request contained invalid data."
 }
}

Question

Why is this happening and what can I do to fix it?

Glorygloryofthesnow answered 9/12, 2018 at 16:0 Comment(4)
Run gcloud info. Near the bottom of the output will be the gcloud logging directory. Run your command again and then look at the log file. You can control the amount of logged information with --verbosity= (debug, info, warning, error, critical, none) options.Lilla
Most likely your hotspot is play with HTTP headers: tethered 4G hotspot via my Samsung Galaxy S8.Lilla
That seemed to have been the cause. Do you suggest there is a fix to the issue?Glorygloryofthesnow
One method is to use Cloud Shell in your browser.Lilla
G
14

Apparently it had to do with my tethered connection. It works from my network at home. So this isn't really an issue with gcloud. However, I still don't know why it doesn't work when using my phone network.

Glorygloryofthesnow answered 9/12, 2018 at 18:7 Comment(2)
Your tethered connection is probably giving you an IPv6 address. AFAIK Cloud SQL Postgres doesn't yet speak IPv6; there's a feature request for IPv6 + Cloud SQL v2 at issuetracker.google.com/72219717Paisley
gcloud beta sql connect will connect via Cloud SQL Proxy, and work with IPV6 addresses.Infancy
W
2

Try connecting using a proxy. Follow the steps provided in the link below-: https://cloud.google.com/sql/docs/postgres/connect-admin-proxy

Or add your server CIDR address using Add networks option in the connections section.

Westernism answered 6/7, 2020 at 20:17 Comment(0)
F
2

I ran into this issue on MacOS as well (not tethering though), and switching ipv6 to link-local only in my Network preferences fixed it. As the comment on the accepted answer mentions, there's still an open feature request about this issue here: https://issuetracker.google.com/issues/72219717.

Fleischman answered 30/7, 2020 at 22:42 Comment(2)
This worked great as a quick simple solutionHubing
worked for me while tethered.Discomposure

© 2022 - 2024 — McMap. All rights reserved.