skip to Main Content

My question is : How this Shiny R code mini web server in JupyterHub could work outside this server (i.e. <> localhost) ?

ui <- fluidPage(
    textInput("caption", "Caption", "Data Summary"),
    verbatimTextOutput("value")
)

server <- function(input, output) {
    output$value <- renderText({ input$caption })
}

shinyApp(ui, server)
Listening on http://127.0.0.1:4844

It works on the local server (127.0.0.1:4844) , but I doesn’t work on http://192.168.x.x:4844

For information. I’ve installed Jupyter and Jupyter Hub, with R Kernel, on Ubuntu 16.04 xenial. I’ve also installed Shiny Server and RStudio Server. Everything works fine. My firewall is off and I have Apache2.

I’ve seen this error on an other mini web server called from Jupyterhub in other mean that Shiny. The same code works in Rstudio Server IDE.

The problem is in the configuration of Jupyter Hub or Shiny Server or in Apache 2 or elsewhere ?

“You are using Jupyter notebook. The version of the notebook server is: 5.4.0
The server is running on this version of Python: Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) [GCC 7.2.0])”.

Thanks in advance.

2

Answers


  1. Chosen as BEST ANSWER

    From @greg L comment. With ShinyApp() wrapped in RunApp() with host="0.0.0.0".

    ui <- fluidPage(
        textInput("caption", "Caption", "Data Summary"),
        verbatimTextOutput("value")
    )
    
    server <- function(input, output) {
        output$value <- renderText({ input$caption })
    }
    
    runApp(shinyApp(ui, server),host = "0.0.0.0")
    

    gave

    Listening on http://0.0.0.0:6596
    

    With http://192.168.x.x:my_port

    • 192.168.x.x : the Shiny Server host
    • my_port: the port given at the launch

  2. Shiny apps listen on 127.0.0.1 (localhost) by default, which only the local machine can access. To make an app accessible to other machines, you can set the host option to 0.0.0.0:

    options(shiny.host = "0.0.0.0")
    

    or

    runApp(host = "0.0.0.0")
    

    See https://shiny.rstudio.com/reference/shiny/latest/runApp.html for more details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search