When your app is deployed to shinyapps.io, it runs on their servers, not in your local machine, so the app doesn't have access to your "localhost", you have to use the public IP of the sql server and make sure that the server accepts remote connections from the shinyapps.io IPs