I created a Postgres Db in AWS RDS for testing (free tier).
In the Db Security group I added my IP as well as I whitelisted the servers listed here.
Everything works fine when I connect to the DB from PgAdmin as well as from RStudio via package DBI I can normally SELECT from tables and INSERT as well using these commands.
server <- function(input, output, session) {
env_vars <- config::get("dataconnection")
conn_expr <- DBI::dbConnect(
RPostgres::Postgres(),
host = env_vars$server,
user = env_vars$uid,
password = env_vars$pwd,
port = env_vars$port,
dbname = env_vars$database
)
user_tbl <- DBI::dbGetQuery(
conn_expr,
"SELECT id, username, password, email FROM userbase"
)
When deploying on shinyapps.io the application does not work! Apparently is not able to connect to the server.
This is the application log message screenshot:
2021-05-22T14:26:22.486101+00:00 shinyapps[4158774]: Starting R with process ID: '26'
2021-05-22T14:26:22.913065+00:00 shinyapps[4158774]:
2021-05-22T14:26:22.913067+00:00 shinyapps[4158774]: Listening on http://127.0.0.1:40904
2021-05-22T14:26:30.262245+00:00 shinyapps[4158774]: Warning: Error in : could not connect to server: No such file or directory
2021-05-22T14:26:30.262247+00:00 shinyapps[4158774]: Is the server running locally and accepting
2021-05-22T14:26:30.262248+00:00 shinyapps[4158774]: connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
2021-05-22T14:26:30.262248+00:00 shinyapps[4158774]:
2021-05-22T14:26:30.274316+00:00 shinyapps[4158774]: 65: <Anonymous>
2021-05-22T14:26:30.274385+00:00 shinyapps[4158774]: Error : could not connect to server: No such file or directory
2021-05-22T14:26:30.274386+00:00 shinyapps[4158774]: Is the server running locally and accepting
2021-05-22T14:26:30.274387+00:00 shinyapps[4158774]: connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
2021-05-22T14:26:30.274387+00:00 shinyapps[4158774]:
app URL: https://bluetti.shinyapps.io/microtest/
I am not sure if it depends on how the .Renviron file is created. I have all the credentials stored there.
My app is running correctly when launched from RStudio, so if there is a good soul who already encounter this issue and is keen to provide some tips on what I am doing wrong, or what I should read, I am grateful since now.
Thanks