Running the notebook on a remote server

Jupyter hub

With JupyterHub you can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server.

Project Jupyter created JupyterHub to support many users. The Hub can offer notebook servers to a class of students, a corporate data science workgroup, a scientific research project, or a high performance computing group.

However, if you are the only one using the server and you just want a simple way to run the notebook on your server and access it through the web interface on a light client without having to install and configure the jupyter hub, you can do the following.

Problem with jupyter notebook

On your server, run the command

jupyter-notebook

you should get something like :

[I 11:18:44.514 NotebookApp] Serving notebooks from local directory: /volume2/homes/admin
[I 11:18:44.515 NotebookApp] 0 active kernels
[I 11:18:44.516 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=357587e3269b0f20f2b7e1918492890ae7573ac7ef1d2023
[I 11:18:44.516 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 11:18:44.519 NotebookApp] No web browser found: could not locate runnable browser.
[C 11:18:44.520 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=357587e3269b0f20f2b7e1918492890ae7573ac7ef1d2023

and if you try to connect to your server ip (in my example : http://192.168.1.2:8888/?token=357587e3269b0f20f2b7e1918492890ae7573ac7ef1d2023) you will get an "ERR_CONNECTION_REFUSED" error. This is because, by default, Jupyter Notebook only accepts connections from localhost.

Allowing connexions from other sources

From any IP

The simplest way to avoid the connection error is to allow the notebook to accept connections from any ip

jupyter-notebook --ip=*

you will get something like

[W 11:26:45.285 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 11:26:45.342 NotebookApp] Serving notebooks from local directory: /volume2/homes/admin
[I 11:26:45.342 NotebookApp] 0 active kernels
[I 11:26:45.343 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=52af33d628881824968b4031967e8541a27cc28b1720c199
[I 11:26:45.343 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 11:26:45.346 NotebookApp] No web browser found: could not locate runnable browser.
[C 11:26:45.347 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=52af33d628881824968b4031967e8541a27cc28b1720c199

and if you connect form a remote client (192.168.1.1 in my example), the following line will be added to the output :

[I 11:26:54.798 NotebookApp] 302 GET /?token=52af33d628881824968b4031967e8541a27cc28b1720c199 (192.168.1.1) 111.17ms

note that you should only do that if you are the only one using the server because the connection is not encypted.

From a specific IP

You can also, explicitly specify the ip of the client

jupyter-notebook --ip=192.168.1.1
[I 11:44:58.104 NotebookApp] JupyterLab extension loaded from C:\Users\Guillaume\Miniconda3\lib\site-packages\jupyterlab
[I 11:44:58.104 NotebookApp] JupyterLab application directory is C:\Users\Guillaume\Miniconda3\share\jupyter\lab
[I 11:44:58.244 NotebookApp] Serving notebooks from local directory: C:\Users\Guillaume
[I 11:44:58.245 NotebookApp] 0 active kernels
[I 11:44:58.245 NotebookApp] The Jupyter Notebook is running at: http://192.168.1.1:8888/?token=503576dd8fa87d1f2c416df307e9b900e520b4942e317b32
[I 11:44:58.245 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:44:58.258 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://192.168.1.1:8888/?token=503576dd8fa87d1f2c416df307e9b900e520b4942e317b32
[I 11:44:59.083 NotebookApp] Accepting one-time-token-authenticated connection from 192.168.1.1