So a couple of quick things…
first, you shouldn’t use the public IP.
Second, you should use UNIX sockets.
You should use a Cloud SQL Proxy.
Your string should be like this:
postgresql://username:password@/dbname?
host=/cloudsql/project:region:instance
just replace with your info.