Connecting VS Code to a remote JupyterHub kernel lets you run Jupyter notebooks in your local editor while using the environments and compute power of the remote server.

Connecting VSCode to JupyterHub

1

Install the JupyterHub extension

Install Microsoft’s JupyterHub extension for VSCode. You can install the extension directly in VSCode or from the CLI:
  1. Open VSCode.
  2. Open the extensions menu.
  3. Search for and install Microsoft’s JupyterHub extension: ms-toolsai.jupyter-hub.
The VSCode JupyterHub extension homepage
By default, Microsoft’s Jupyter extension for VSCode collects usage data and sends it to Microsoft. However, you can disable this telemetry reporting, if necessary. For more information, see Microsoft’s privacy statement.
The JupyterHub extension also installs:
ExtensionID
Jupyterms-toolsai.jupyter
Jupyter Keymapms-toolsai.jupyter-keymap
Jupyter Notebook Renderersms-toolsai.jupyter-renderers
Jupyter Slide Showms-toolsai.vscode-jupyter-slideshow
Jupyter Cell Tagsms-toolsai.vscode-jupyter-cell-tags
2

Generate a JupyterHub API token

To authenticate VSCode with JupyterHub, you need an API token:
  1. Open a browser and navigate to your JupyterHub dashboard URL: https://<YOUR_JHUB_DOMAIN>/hub/token.
  2. Enter a brief, descriptive note about your token’s use.
    Defaults to “Requested via token page” if not provided.
  3. Select an expiration date for your token.
  4. Leave the Permissions box empty.
  5. Select Request new API token.
  6. Copy your new API token and save it in a secure location. You won’t be able to see it again.
3

Connect VSCode to JupyterHub

  1. Open VSCode.
  2. Open the File menu and select New File….
  3. Select Jupyter Notebook from the available options.
    New File menu options
  4. Open the Select Kernel menu and select Existing JupyterHub Server….
    VSCode select kernel button
  5. Enter the URL of your JupyterHub server.
  6. Enter your JupyterHub username.
  7. Paste the API token you generated earlier to authenticate VSCode to the server.
  8. (Optional) Set the name of your JupyterHub connection.
  9. VSCode establishes a connection to the remote JupyterHub kernel and provides you with a list of available kernels to use. Select the kernel you want your local notebook to use.
4

Verify

Verify the kernel is running on the remote server by running !hostname in the first cell. This prints the IP address of the JupyterHub server.
Return from hostname verification command

Troubleshooting

VSCode says my JupyterHub server URL is invalid