code-server (VS Code in the browser)¶
code-server lets you run a full VS Code environment on a compute node and access it from any browser. No local installation needed, no extensions to configure on your machine. Just submit a job, open a URL, and start coding.
If you already use VS Code Remote SSH, think of code-server as the lighter alternative: everything happens in the browser, and any device with a web browser can be your workstation.
-
No install required
Works on any device with a browser. Laptop, tablet, a colleague's machine.
-
Quick setup
Submit a job, open a URL. Ready in under a minute once the job starts.
-
Persistent state
Extensions, settings, and kernels persist across sessions. Set up once, use forever.
-
Runs on compute nodes
Your code runs where the resources are, not on your local machine or login nodes.
| code-server | VS Code Remote SSH | |
|---|---|---|
| Local install | None (just a browser) | VS Code + Remote SSH extension |
| Access from | Any device with a browser | Only machines with VS Code installed |
| Extensions | Installed on the server, persist across sessions | Installed on the server via VS Code |
| Availability | Hyperion | All clusters |
Availability
code-server is currently available on Hyperion only. We are working on making it available on Atlas EDR and Atlas FDR as well.
How it works¶
Since compute nodes are not directly accessible from outside the cluster, the setup involves three pieces:
- A batch job that starts code-server on a compute node
- An SSH tunnel from your local machine through the login node to the compute node
- Your browser pointing to
localhost
For more details on how SSH tunneling works, see the SSH tunneling section in the connection guide.
The following video walks through the entire process from start to finish:
Step 1: Submit the batch script¶
Save the following as code-server.sh:
#!/bin/bash
#SBATCH --job-name=code-server
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=16G
#SBATCH --time=8:00:00
#SBATCH --qos=regular
#SBATCH --output=code-server-%j.log
module load DIPC-Utils
start-code-server
The start-code-server script takes care of everything: it launches code-server, waits for it to be ready, and prints the connection information to the log file.
Submit it:
sbatch code-server.sh
If you are not familiar with the #SBATCH flags, the SLURM reference explains each directive in detail. Adjust --cpus-per-task, --mem, and --time to fit your needs.
Options
start-code-server accepts optional flags:
| Flag | Description | Default |
|---|---|---|
--port, -P |
Port to listen on | 8080 |
--password, -p |
Set a custom password | Auto-generated |
For example:
start-code-server --port 9090 --password mysecretpass
Step 2: Check the log¶
Wait for the job to start running:
squeue -u $USER
Once the state changes to R (running), read the log file:
cat code-server-<JOBID>.log
You will see something like this:
========================================
code-server is running
========================================
Node: hyperion-039
Port: 8080
1. SSH tunnel (run on your local machine):
ssh -L 8080:hyperion-039:8080 <username>@hyperion.sw.ehu.es -N
2. Open in your browser:
http://localhost:8080
3. Password: d51867d0ad62e2affc717da9
========================================
The log gives you everything you need: the tunnel command, the URL, and the password.
About the password
The first time you run code-server, it generates a random password stored in ~/.config/code-server/config.yaml. This password persists across sessions, so you only need to look it up once. To use a custom password, pass --password or -p to start-code-server.
Step 3: Create the SSH tunnel¶
On your local machine, open a terminal and run the tunnel command from the log:
ssh -L 8080:hyperion-039:8080 <username>@hyperion.sw.ehu.es -N
This forwards your local port 8080 through the login node to port 8080 on the compute node. The terminal will appear to hang with no output; that is normal.
Port already in use
If port 8080 is taken on your machine, pick another local port: ssh -L 9090:hyperion-039:8080 ... and then open http://localhost:9090 instead.
Step 4: Open your browser¶
Navigate to:
http://localhost:8080
Enter the password from step 2. You now have a full VS Code environment running on a compute node.
Working with your files¶
code-server starts in your home directory by default. To open a project on /scratch:
- Click File > Open Folder
- Navigate to
/scratch/<username>/your-project - Click OK
Working directory
For job-related data, work from /scratch. See the Data transfer page for an overview of the available filesystems.
Extensions¶
code-server uses the Open VSX registry instead of the Microsoft Marketplace. Most popular extensions (Python, Jupyter, GitLens, etc.) are available there.
To install an extension:
- Open the Extensions panel from the left sidebar (or press
Ctrl+Shift+X) - Search for the extension you want
- Click Install
Extensions are installed on the cluster in ~/.local/share/code-server/extensions/ and persist across sessions, so you only need to install them once.
Running Jupyter notebooks¶
code-server can run Jupyter notebooks directly in the browser, just like the desktop version of VS Code.
Install the required extensions¶
From the Extensions panel (Ctrl+Shift+X), search and install:
- Python
- Jupyter
The following video shows how to install both extensions:
You only need to do this once; the extensions persist across sessions.
Register your conda environment as a kernel¶
code-server will not automatically detect conda environments. You need to register them as Jupyter kernels explicitly. This is a one-time step per environment.
Open the integrated terminal (Ctrl+`) and load the module:
module load Miniforge3
Then activate your environment and register it. The steps depend on whether your environment has a name or only a path prefix:
conda activate my_environment
python -m ipykernel install --user --name=my_environment --display-name "My Environment"
Some environments created with conda create --prefix /path/to/env do not have a name, only a path. You can activate them by path and choose any kernel name you want:
conda activate /scratch/$USER/env/my_project
python -m ipykernel install --user --name=my_project --display-name "My Project"
You can check which case applies to your environments with conda env list. Named environments show a name on the left; prefix-only environments show only the path.
If ipykernel is not installed in your environment, add it first:
conda install ipykernel
See Adding custom kernels for more details on managing kernels.
Open a notebook and select the kernel¶
- Open a
.ipynbfile from the file explorer (or create one with File > New File and save it as.ipynb) - In the top right corner of the notebook, click Select Kernel
- Choose Jupyter Kernel
- Select the kernel you just registered (e.g., "My Project")
Ignore the /usr/bin/python kernel
By default, code-server may show a kernel pointing to /usr/bin/python. This is the system Python, which lacks scientific packages. Always select the kernel you registered from your conda environment.
You can now run cells and they will execute on the compute node using the packages from your selected environment.
First-time setup
If you have not set up a conda environment yet, the Your first Python environment guide walks you through creating one from scratch.
Stopping the server¶
To end your code-server session, cancel the batch job:
scancel <JOBID>
You can find the job ID with squeue -u $USER.
Troubleshooting¶
Cannot reach localhost:8080 in the browser
Make sure the SSH tunnel is active and using the correct hostname and port. Verify the job is still running with squeue -u $USER.
Invalid password
Check the password in ~/.config/code-server/config.yaml, or set one explicitly with the PASSWORD environment variable.
Cannot copy/paste in the terminal
Browsers restrict clipboard access for security. Use Ctrl+Shift+C to copy and Ctrl+Shift+V to paste in the integrated terminal. If that does not work, make sure you have allowed clipboard permissions for localhost:8080 in your browser settings.
Extensions not found in Open VSX
Some Microsoft-exclusive extensions (like the official C# or Remote SSH) are not available on Open VSX. Check open-vsx.org for alternatives.
Modules not available in the integrated terminal
If module commands are not recognized, your shell initialization files may not be sourced. See the Shells and dotfiles page.
Kernel selector shows /usr/bin/python instead of my environment
You need to register your conda environment as a Jupyter kernel. See Register your conda environment as a kernel above.
See also¶
-
VS Code Remote SSH
Connect VS Code on your local machine to a compute node via SSH.
-
Jupyter Notebook
Run Jupyter notebooks on compute nodes via SSH tunnel.
-
Python environments
Set up conda environments and install packages.
-
Environment modules
Load software and manage dependencies with
module.