Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pgadmin4 connect to postgres in Google Cloud SQL

I am not able to connect through pgAdmin4 to Google Cloud SQL. Following are the credentials I am providing and getting the error messege:

enter image description here

enter image description here

like image 487
Apu Avatar asked Sep 01 '26 06:09

Apu


1 Answers

To connect with Google Cloud SQL using pgadmin client, you should use cloud_sql_proxy

These are the steps you need to follow:

Note: on Linux, the proxy is often called cloud_sql_proxy, on Windows, it is typically cloud-sql-proxy, or cloud-sql-proyx.x64. Make sure the binary is accessible through your PATH.

  1. Get the connection string, or connection name from GCP here: enter image description here

  2. Establish connection to Postgres.

    a) On older cloud proxy versions:

     cloud_sql_proxy -instances=<connection_string>=tcp:5433
    

    b) on recent (2024 and later) cloud proxy versions:

     cloud-sql-proxy <connection_string> --port 5433 --run-connection-test
    

    (the added --run-connection-test will ensure that the connection works by testing the connection, otherwise the proxy will exit).

  3. If you receive an error on the port, it may be in use. Choose a different port like 5434 or anything, really.

    After executing cloud_sql_proxy, you will see something like this enter image description here

  4. Now create a new server connection using pgadmin client. Use the port number you specified in step (2).

    enter image description here

    enter image description here


If you followed those steps properly it will connect and you can use it as if you were using a local pgadmin install.

like image 186
Arif Avatar answered Sep 03 '26 19:09

Arif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!