Search code examples
google-cloud-platformgoogle-cloud-datalab

why am I able to SSH from command line, but not from `datalab connect`?


I've been playing with google datalab and it's hard to get a connection to the notebook

I can create/launch an instance successfuly but usually the notebook is unavailable

$ datalab create [instance]
Connecting to [instance].

This will create an SSH tunnel and may prompt you to create an rsa key pair. To manage these keys, see https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys
Waiting for Datalab to be reachable at http://localhost:8081/
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
Connection broken
Attempting to reconnect...
Waiting for Datalab to be reachable at http://localhost:8081/

however, even while the notebook is unavailable, I can always SSH from the console

gcloud compute --project "[project]" ssh --zone "asia-east1-a" "[instance]"

sometimes I ^C and try again with datalab connect [instance] and it will eventually work. Am I doing anything wrong, or is it just hit/miss?


Solution

  • It sometimes takes a few minutes for datalab to connect. If it does not connect, I also do as you describe and open a new Cloud Shell window (or use tmux to start another "tab") to run datalab connect [env] which usually works.

    I believe this delay occurs because the web/notebook server takes time to start up after the environment is built.