R Shiny App Fails to Connect

I am trying to deploy a Shiny app on one of our systems. After launching the app and trying to connect, I receive a “fail to connect to /<port?” error. If I start a VNC session and ssh into the node running the program, I can launch a web browser and connect to the app. Any suggestions on where the error might be occurring or any advice would be greatly appreciated. Thanks!

Hi and welcome!

First off, love that movie, great choice of image.

Secondly, and to answer your question, here’s a couple things I would check.

  • First I’d check to see if you’re binding on a public interface or the localhost when you call runApp. Looking at the documentation it defaults to 127.0.0.1 which is the local interface meaning you can only connect to it through localhost (that’s why you can connect to it through ssh/browser on the same machine)

Here’s an example specifying the host as 0.0.0.0 which I think is all public interfaces? You can also specify the hostname here.

shiny::runApp("app.R", port = 3838, host = "0.0.0.0")'
  • Then when testing or trying to verify, you can do the same as you’ve done in your initial comment, but I wouldn’t use localhost to connect to it. I’d use the actual hostname because this is what apache on the web node is using. You can try this in a browser or by getting an ssh session on the OnDemand web node and using curl.

Using curl on the OnDemand web node may tell you more. Either you’re app isn’t bound to a public interface (i.e., it’s only reachable through localhost) or you don’t have actual network connectivity between the Ondemand web node and the compute node running the app (or more specifically, you don’t have network connectivity to that port specifically).

Thank you for the prompt reply! I got it to work (kind of) with changing the host to 0.0.0.0 as you suggested. However, when I click to connect to the application, I get a page that says ‘Not Found’. But, if I copy the url and paste it into a new tab it connects to the app. Refreshing the original ‘Not Found’ page does not work. Do you have any insights into this?

Can you share your view.html.erb? Also I’d probably have to see the network tab of your developer tools (only Chrome will open developer tools on new tabs) just to see if it’s apache sending the page or your origin server (your rshiny app).

As an off the top guess - you’re using a POST request from a form tag and you should use method=get (the default is post in forms) if that’s what your server is setup to respond to.

Wow. Jeff with the no-scope solve from the hip! I was using a POST request instead of get. That solved the problem. Thanks!

Here is the revised view.html.erb for posterity:

<form action="/rnode/<%= host %>/<%= port %>/" method="get" target="_blank">
  <input type="hidden" name="password" value="<%= password %>">
  <button class="btn btn-primary" type="submit">
    <i class="fa fa-eye"></i> Connect to ShinyApp
  </button>
</form>
1 Like