Alwyn Mathew     Publication     Talks     Teaching     Blog     Resume

Jupyter notebook on remote server

This will help to configure to access remotely running jupyter notebook from local machine.

To configure you will need jupyter notebook configure file. You can create a jupyter_notebook_config.py file, with all the defaults commented out, by:

jupyter notebook --generate-config

By default, Jupyter Notebook only accepts connections from localhost (eg, from the same computer that its running on). By modifying the NotebookApp.allow_origin option from the default ‘ ‘ to ‘*’ in jupyter_notebook_config.py, you allow Jupyter to be accessed externally.

c.NotebookApp.allow_origin = '*' #allow all origins

You’ll also need to change the IPs that the notebook will listen on:

c.NotebookApp.ip = '0.0.0.0' # listen on all IPs

Launch Jupyter Notebook from remote server using port :

jupyter notebook --no-browser --port=<port>

Or run the following command to launch with default port:

jupyter notebook --no-browser

Method 2

You can also access the notebook from your remote machine over SSH by setting up a SSH tunnel. Run the following command from your local machine:

ssh -L <port>:localhost:<port> <remote_user>@<remote_host>

Method 3

You can decide on runtime with the same result, but without the need for a configuration file

jupyter notebook --ip 0.0.0.0

Conda env in Jupyter

If your conda environments are not showing up in Jupyter notebook, you probably do not have nb_conda_kernels installed in the environment where Jupyter is installed. Anaconda’s documentation states that

nb_conda_kernels should be installed in the environment from which you run Jupyter Notebook or JupyterLab. This might be your base conda environment, but it need not be.

For instance, if the environment notebook_env contains the notebook package, then you would run

conda install -n notebook_env nb_conda_kernels