Running Jupyter From Remote Server

1 minute read


Running Jupyter from Remote Server

The instruction is borrowed from this post


  • generate Jupyter config file. You will need this later to store password.
$ jupyter notebook --generate-config
Writing default config to: /home/usrname/.jupyter/
  • generate password (also see this doc). Enter and verify your password.
$ jupyter notebook password
Enter password:  ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /home/usrname/.jupyter/jupyter_notebook_config.json

Run Jupyter from remote server

Here, I use as a remote server. ssh into your remote server, and type the following command.

usrname@pinklady $ jupyter lab --no-browser --port=8888

Note, port number 8888 is the default one that Jupyter uses, but you can change it to any other number theretically as long as it is not occupied (e.g., 8889, 8890, …)

Forward port between remote and local

In your local machine, using ssh and the following to forward port. You will be prompted to enter your password you used to log into remote server.

$ ssh -N -f -L localhost:8889:localhost:8888's password: 

Note, the first port number 8889 is the one used on your local machine. Similarly, you can switch it to other available port number (8888, 8890 and etc.). If the port number you are trying to use is occupied, you can use the following command (on Mac) to kill other processes that are listening to it, by

$ lsof -i TCP:8889
ssh     47477 shua784    7u  IPv6 0xfb88ca04eb4d849d      0t0  TCP localhost:ddi-tcp-2 (LISTEN)
ssh     47477 shua784    8u  IPv4 0xfb88ca04e68b58dd      0t0  TCP localhost:ddi-tcp-2 (LISTEN)

Then, kill the proceeses using PID

$ kill 47477

Lauch Jupyter notebook

Open a browser in your local machine, and enter the following url in your address bar:


It will open a new window and redirect you to the Jupyter home page. You will need to enter the jupyter notebook password from the first step.