Lifecycle for servers started by jupyter server proxy

Hi all,

I’m pretty new to the jupyter ecosystem, but have enjoyed what I’ve been able to do so far, thanks to everyone who has been working on this!

I was hoping to use jupyter server proxy as a direct front end to some shiny apps I have written so that I can share them with some jupyter users (eg directly run the shiny app without using something like shiny server). I know that this is an unusual way to have a web app, but my ideal lifecycle is to have the shiny app quit when the user is not using it.

However, when I have the shiny app close, the proxy layer does not seem to start another instance of my app, instead I get a page that says [Errno 111] Connection refused.

Is there a way that I could indicate to the proxy that the app has closed and it needs to start it from scratch?

I’ve also noticed that sometimes old processes stick around after shutting down the user’s jupyter hub, which seems like it would be a problem if the app didn’t automatically close.

I’m having trouble thinking of a way to share a fully reproducible example, but here’s a shiny app that closes when it’s disconnected from:


port <- as.numeric(commandArgs(trailingOnly = TRUE)[1])

n <- 200
  port = port,
    ui = bootstrapPage(
      numericInput('n', 'Number of obs', n),
    server = function(input, output, session) {
      session$onSessionEnded(function() {
      output$plot <- renderPlot({

This R script is called from the Server Process configuration with a single argument {port}. I’ve done this with a file with the following:

c.ServerProxy.servers = {
    'test': {
        'command': ['Rscript', 'test.r', '{port}']

Have you considered checking out Binder for something like this? E.g., here’s an example repo that sets up Shiny on

This is pretty great :slight_smile:

Have you looked at for shiny? shiny likes having a config file for it, and that sets it up properly. Give that a shot?

Can you also tell me more about it leaving processes behind? What kinda processes are these?

Looks very cool, but I need to run the apps on a local machine.

That’s for shiny server though, I was hoping to run shiny apps just from the R command line, because shiny server seems like it’s doing essentially the same thing as jupyter server proxy (running a shiny app and proxying the port). Perhaps this is misguided though, so I’ll take a closer look at shiny server.

As for what process is being left behind, what I’m seeing is when I’m running stuff on a multi-user jupyter lab instance, after I shut down the my hub (the red “stop my server” button from, the old R process is still running. If I restart the server and try to get back to the proxied URL, jupyter server proxy starts another process and proxies to that one, meaning that 2 processes are running.

Oh, I think this #FIXME is talking about what I was hoping for.

Thanks again for all the great work, I’m excited to see it develop!