0

Hi I wanted to connect to Postgres that I created on Google Cloud SQL using psql. In the instruction it says to connect to the database do this

psql "sslmode=disable dbname=postgres user=postgres hostaddr=INSTANCE_IP"

I have tried to do so using my Terminal on my Linux laptop, but after I press enter, nothing happen... I'm confused what to do next? How should I create a table, query etc?

enter image description here

4
  • How did you configure your Cloud SQL instance connectivity? Public IP is enabled? Did you authorize your home network? (or wherever you're running psql from) Commented Aug 4, 2022 at 17:52
  • Also, does the connection eventually timeout (I suspect you're waiting on a TCP timeout which means 45-60 seconds). Commented Aug 4, 2022 at 17:52
  • Hey @GabeWeiss sorry for my late reply. I have enabled public IP and have added my home network. I just tried it again today and it worked. I guess it just takes a few hours until it works... Because I didn't change anything and now it works. Commented Aug 9, 2022 at 13:13
  • 1
    No worries! If you created the instance without the authorized network, then after it's created add your authorized network, it DOES take a minute or two to activate. Shouldn't be that long? But either way, glad it's working for you now! Commented Aug 10, 2022 at 15:58

1 Answer 1

1

I've managed to connect to my PostgreSQL successfully by following the documentation you provided.

Instead of using What's My IP, I've used the public IP assigned for my instance:

1

After executing this code on my terminal:

psql "sslmode=disable dbname=postgres user=postgres hostaddr=[public-ip-address]"

I've successfully connected to my PostgreSQL instance. See screenshot below:

2

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I also use that Public IP Address, but I don't know why it didn't work last time. Now it works already, maybe it just takes a few hours to be active (?) Thanks for anwering.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.