RStudio Server

How to run RStudio Server on a compute node through an SSH tunnel.

This page describes a standard pattern to run RStudio Server on a compute node and reach it safely through an SSH tunnel.

Why This Requires a Compute Node

RStudio Server is an interactive service and must not be started on the login node.

The correct workflow is:

  1. connect to the login node
  2. request a SLURM allocation on a compute node
  3. start RStudio Server inside that allocation
  4. open an SSH tunnel from your local machine through the login node to the compute node
  5. connect with a browser to http://127.0.0.1:PORT

Start an Interactive Allocation

For a lightweight RStudio Server session on the CPU partition, request one CPU:

srun --partition=cpu --ntasks=1 --cpus-per-task=1 --time=02:00:00 --mem=8G --pty bash

When the shell starts, verify that you are on a compute node:

hostname

Keep this shell open. RStudio Server will run there.

Load the Required Environment

Load the modules you need for R and for RStudio Server. The exact module names may depend on how the service is exposed on NowWhat.

Typical pattern:

module purge
module load apptainer-rstudio-server

Start RStudio Server on the Compute Node

Choose a port that is free on the compute node, for example 8787, and bind the service to localhost:

rstudio --ip 0.0.0.0 --port 8787

If your installation exposes a different startup command, adapt the example accordingly. The important part is that the service runs on the compute node and listens only on 127.0.0.1.

Create the SSH Tunnel

Assume:

  • your username is your_username
  • the login node is nowwhat.stat.unipd.it
  • the compute node hostname returned by hostname is wn01
  • RStudio Server is listening on port 8787

From your local machine, create the tunnel:

ssh -N -L 8787:wn01:8787 your_username@nowwhat.stat.unipd.it

The tunnel path is:

your laptop -> login-nowwhat -> wn01:8787

In this setup:

  • the browser connects to 127.0.0.1:8787 on your machine
  • SSH forwards that traffic through the login node
  • the final destination is port 8787 on the compute node where RStudio Server is running

Leave this SSH command running while you use RStudio Server.

Open RStudio Server in the Browser

Open:

http://127.0.0.1:8787

If the service requires authentication, use the credentials or token provided by the launched RStudio Server instance.

Important Notes

  • do not start RStudio Server on the login node
  • the SSH tunnel must be opened from your local machine, not from the compute node
  • if the SLURM allocation ends, the service and the tunnel become invalid
  • if port 8787 is already in use, choose another local and remote port consistently

Minimal Session Checklist

  1. ssh your_username@nowwhat.stat.unipd.it
  2. srun --partition=cpu --ntasks=1 --cpus-per-task=1 --time=02:00:00 --mem=8G --pty bash
  3. hostname
  4. module purge && module load apptainer-rstudio-server
  5. rstudio --ip 0.0.0.0 --port 8787
  6. from your local machine, run ssh -N -L 8787:wn01:8787 your_username@nowwhat.stat.unipd.it
  7. open http://127.0.0.1:8787