Hello Kirtan,
Is the PostgreSQL instance running in the cloud platform as Cloud SQL for PostgreSQL, or in the compute engine environment? Is it external to the GCP?
It may be worthwhile checking the postgresql.conf file and make sure that listen_addresses is not set to localhost.
How did you configure client identification in the pg_hba.conf file? You may gather related information on "The pg_hba.conf File" documentation
page.