Connect to JupyterLab

When you start a Deep Learning VM Images instance, a JupyterLab session is initialized.

To set up SSH port forwarding, complete the following steps, and then access your JupyterLab session through a local browser:

  1. Run the following command by using the Google Cloud CLI in your preferred terminal or in Cloud Shell:

    gcloud compute ssh \
        --project PROJECT_ID \
        --zone ZONE \
        -- -L 8080:localhost:8080

    Replace the following:

  1. Access your JupyterLab session through a local browser:

    • If you ran the command on your local machine, visit https://localhost:8080 to access JupyterLab.

    • If you ran the command using Cloud Shell, access JupyterLab through the  Web Preview on port 8080.


Symptom: When using SSH port forwarding to connect to JupyterLab, you are unable to connect to the instance.

Problem: You are trying to connect to the wrong TCP socket.


  • On some Linux clients, the localhost resolves to the IPv6 loopback address (::1). Check this by using ping -c 1 localhost. If this command returns the IPv6 address, use -L 8080: (rather than -L 8080:localhost:8080) in the gcloud compute ssh command.

  • Ensure that you connect to http://localhost:8080 (instead of https://localhost:8080) on your local client.