---
title: "Visual Studio Code (VSCode) Guide"
canonical: "https://kb.uconn.edu/space/SH/26626326576/Visual%20Studio%20Code%20(VSCode)%20Guide"
format: markdown
---
> Macro (toc)

## What is [VSCode](https://code.visualstudio.com/)?

Visual Studio Code, commonly known as VSCode, is a highly popular, free and open-source code editor developed by Microsoft. It’s available for Windows, Linux and macOS. VSCode is widely recognized for its performance, versatility and user-friendly interface, making it a preferred choice for developers across various programming languages and frameworks.

## Why use VSCode?

One of the key strengths of VSCode is its versatility. It supports a wide range of programming languages on install and its functionality is greatly expanded through a large marketplace of extensions. Just to name a few, the extensions offer support for additional languages, debuggers, and tools for software development and data visualization. 

In an HPC environment, VSCode is among the best utilities for programming due to its remote capabilities. It allows users to write, run, and test code within the VSCode interface while utilizing the storage and computational resources of the cluster. This can drastically simplify research workflows, as large data files and/or analysis scripts do not need to be transferred between the HPC and local computers. 


> ⚠️ **Notice for VSCode on Storrs HPC**
> ⚠️ 
> ⚠️ All VSCode instances should be created as interactive sessions through SLURM. Other methods disrupt the equitable distribution of HPC resources and <u>**violate**</u> the [Storrs HPC Usage Policy](https://kb.uconn.edu/space/SH/26032800737/Storrs+HPC+Usage+Policy) and users who do this will have their processes <u>**terminated**</u>.

## How to Use VSCode on Storrs HPC?

In short, we use [Remote Tunnels](https://code.visualstudio.com/docs/remote/tunnels) by VSCode to connect. 

To start, create an [interactive session](https://uconn.atlassian.net/wiki/spaces/SH/pages/26032963685) using `srun`:

```
(base) [jth12345@login6 ~]$ srun --ntasks=1 --nodes=1 --mem=16G --partition=general --time=6:00:00 --pty bash
srun: job 5341738 queued and waiting for resources
srun: job 5341738 has been allocated resources
(base) [jth12345@cn590 ~]$
```

Next, load the VSCode module:

```
(base) [jth12345@cn590 ~]$ module load vscode/
```

Start the tunnel:

```
[jth12345@cn566 ~]$ module load vscode
Loading vscode/2025
  Loading requirement: pre-module post-module
[jth12345@cn566 ~]$ tunnel
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
? How would you like to log in to Visual Studio Code? ›
❯ Microsoft Account
  Github Account
```

Using the arrow and enter keys, select “Microsoft account” to log in. 

```
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
✔ How would you like to log in to Visual Studio Code? · Microsoft Account
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ******** to authenticate.

```

Go to `https://microsoft.com/devicelogin` and enter the code given:

![image-20240118-223618.png](media://1fa753b7-c17c-438e-83c9-8fd12541c1f4)

After this, you should be able to securely log in with your **UConn email**. 

If it is your first time, you will be asked to name the tunnel. Any name will work here. For this example, we are using “jonathan_vscode”. 

```
✔ What would you like to call this machine? · jonathan_vscode
[2024-01-18 17:39:56] info Creating tunnel with the name: jonathan_vscode
[2024-01-18 17:39:56] info Adopting existing tunnel (ID=ID { cluster: "use", id: "tqrqw590" })

Open this link in your browser https://vscode.dev/tunnel/jonathan_vscode
```

Finally, using the given link, you should be able to access VSCode in your browser!

> 📝 **Properly exiting VSCode**
> 📝 
> 📝 To exit VSCode, Ctrl+C the tunnel and use `exit` to terminate the interactive session.

## Connecting with your local VSCode application

While the in-browser version of VSCode works fine, generally, it is more convenient to connect through the VSCode app on your local machine. This can be done through the “Remote - SSH” and “Remote - Tunnels” extensions.

1. Open VSCode
2. Make sure to have the “Remote - SSH” extension and the “Remote - Tunnels” extension installed.
3. Log in or confirm that you’re logged into your Microsoft account on VSCode
  1. If you’re not signed in, click the account icon on the bottom left and “sign in to sync settings”
4. “Ctrl + Shift + p” and search “Remote-Tunnels: Connect to Tunnel

![image-20240118-230006.png](media://e8222aea-1084-4122-9d5c-c2dd514f925a)

4. Choose the account you logged in with
5. You should now see any session names, node names, and the status (online/offline) for selection





## Initiating the Slurm job from within VSCode 

> ❌ Connections using VS-Code directly to HPC are no longer supported since the RHEL9.6 HPC upgrade, please submit a job to a compute node and connect to VS-code using the above steps.

It is possible to start a session entirely within VSCode, bypassing the regular ssh connection to the HPC. While we recommend the prior method, the instructions for this are as follows:

1. Open VSCode
2. Used Ctrl+Shift+P and clicked Remote-SSH: Connect to host... to connect to [hpc2.storrs.hpc.uconn.edu](https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhpc2.storrs.hpc.uconn.edu%2F&data=05%7C02%7Ctechsupport%40uconn.edu%7C236112e015d24b612e5a08dc21d74268%7C17f1a87e2a254eaab9df9d439034b080%7C0%7C0%7C638422455675048482%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=g43lQtEcJWQBlcijXEzcZIVOUgsibkNT8MwC6dAGfYM%3D&reserved=0)
3. Enter your password
4. In the login node terminal, start an interactive session (i.e., `srun --ntasks=1 --nodes=1 --mem=16G --partition=general --time=6:00:00 --pty bash`)
5. Run `module load vscode`
6. Run `tunnel`
7. Select "Microsoft Account" to log in and use your UCONN email
8. Enter the code at the link provided

> ⚠️ This next step is critical.

9. Open a NEW VSCode window
10. Continue with the previous [section](https://uconn.atlassian.net/wiki/spaces/SH/pages/26626326576/Visual+Studio+Code+%28VSCode%29+Guide#Connecting-to-this-session-via-your-local-VSCode-application) in this new window


## Jupyter Notebooks on VSCode

Check out our guide here: [Jupyter on VSCode - Storrs HPC - UConn Knowledge Base](https://kb.uconn.edu/space/SH/26640089153/Jupyter+on+VSCode)