Open source shiny server on an instance on gcp couldn't connect to remote database on gcp (cloud SQL)

I am trying to host a shiny app on the open source shiny server which is installed on a virtual machine on gcp.
The app is trying to connect to a remote Postgresql database that's also on gcp's cloud sql.

Below is my code.

library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="test",
                 host="**.**.**.**",
                 user="username",
                 password="pwd", port=5432)

I think I know one of the reason why is not working is because I need to white list the ip address but I'm not sure which ip addresses I need to white list, as I have installed the shiny-server on virtual machine on gcp.

If I publish the app on shinyapps.io server it runs perfectly because I white listed the ip addresses it run on.

Can someone please help in finding the ip address of a shiny-server installed on a virtual machine or any suggestions that would help would be great.

Thanks

Shiny-server is a service running in your virtual machine it doesn't have its own IP, it has its own port, you have to use the public IP of your virtual instance. Also, have in minde that public IPs are dynamic (they change) unless you pay for a static one.

Thanks Andres!
I tested it by assigning a static ip address to my instance and white listed the ip address but still the shiny app didn't work.

Unless you are getting error messages in your apps logs, this has more to do with your system configuration than to Shiny so maybe you should ask this to gcp client support.

nothing in the logs, just says
Listening on [http://127.0.0.1:40525]
Session terminated, terminating shell...

will try to reach gcp client support. Thanks for the help.

My app work's now.
For future users, below is what I did wrong and how I corrected it.
While creating the app on R studio server, I installed all my packages from R studio server. And I didn't thought that these packages are not installed at the root, they were installed at the user level and shiny-server can't access these.
I installed all the required packages again at the root

sudo su - -c "R -e \"install.packages('packagename', repos='https://cran.rstudio.com/')\""

and then my shiny-app works.

The weird thing is that when that happens you usually get error messages in your logs about missing packages.

Yes, that's what I thought too. Would have figured out quickly if it was in the logs.
and I think I was looking for logs at the correct location (var/log/shiny-server), as per rstudio support page.

It seems to me that you were looking at shiny-server.log but you should also look into the app level log files located in the same folder.

I think I was looking at the right location. Please see below image.