Skip to content

JupyterLab

JupyterLab is installed but not running, and the seller settings security group does not open its port, 8888.

Why it is not open to the internet

A notebook can run any code on the instance, so it is safer to reach it through an encrypted tunnel than to open its port. You need your own SSH client, with a key pair or a temporary key from EC2 Instance Connect, or Session Manager. The in-browser EC2 Instance Connect terminal cannot forward ports.

Start it and open it

  1. Connect with a tunnel for port 8888:

    ssh -i <key>.pem -L 8888:localhost:8888 ubuntu@<public-ip>
    
    aws ssm start-session --target <instance-id> \
      --document-name AWS-StartPortForwardingSession \
      --parameters '{"portNumber":["8888"],"localPortNumber":["8888"]}'
    

    Then open a second session to the instance, and run sudo -iu ubuntu in it before the next step.

  2. On the instance, start JupyterLab:

    jupyter lab --no-browser --port=8888
    
  3. It prints a link that starts with http://localhost:8888/lab?token=. Open that link in your browser. The token is what lets you in.

Keep it running after you disconnect

JupyterLab stops when you close the terminal. To keep it running, start it in the background instead, and print its link with the second command:

nohup jupyter lab --no-browser --port=8888 > ~/jupyter.log 2>&1 &
jupyter server list

Where your files live

Notebooks and files you save are kept on the instance's disk in /home/ubuntu. They survive stopping and starting the instance, but are deleted when the instance is terminated, so download anything you want to keep.