Open Jupyter Notebook with http launch instead of redirect file

usefull when starting jupyter notebook from WSL
jupyter
wsl
Published

October 21, 2020

Where is the problem?

Default configuration when launching jupyter notebook is to create a redirect file.

Here is the explanation from config file ~/.jupyter/jupyter_notebook_config.py.

## Disable launching browser by redirect file
#
#  For versions of notebook > 5.7.2, a security feature measure was added that
#  prevented the authentication token used to launch the browser from being
#  visible. This feature makes it difficult for other users on a multi-user
#  system from running code in your Jupyter session as you.
#
#  However, some environments (like Windows Subsystem for Linux (WSL) and
#  Chromebooks), launching a browser using a redirect file can lead the browser
#  failing to load. This is because of the difference in file structures/paths
#  between the runtime and the browser.
#
#  Disabling this setting to False will disable this behavior, allowing the
#  browser to launch by using a URL and visible token (as before).
#c.NotebookApp.use_redirect_file = True

And when launching jupyter notebook from WSL

(xgboost) guillaume@LL11LPC0PQARQ:~/git/d059-vld-ic$ jupyter notebook
[I 13:09:57.346 NotebookApp] The port 8888 is already in use, trying another port.
[I 13:09:57.370 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 13:09:57.371 NotebookApp] Serving notebooks from local directory: /mnt/d/git/d059-vld-ic
[I 13:09:57.372 NotebookApp] The Jupyter Notebook is running at:
[I 13:09:57.373 NotebookApp] http://localhost:8889/?token=c3f77aea548937f5f563e0306d982d4332d26b0ed623e662
[I 13:09:57.373 NotebookApp]  or http://127.0.0.1:8889/?token=c3f77aea548937f5f563e0306d982d4332d26b0ed623e662
[I 13:09:57.374 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:10:00.384 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///home/guillaume/.local/share/jupyter/runtime/nbserver-828-open.html
    Or copy and paste one of these URLs:
        http://localhost:8889/?token=c3f77aea548937f5f563e0306d982d4332d26b0ed623e662
     or http://127.0.0.1:8889/?token=c3f77aea548937f5f563e0306d982d4332d26b0ed623e662

alt text

Solution

As given in https://stackoverflow.com/questions/57679894/how-to-change-jupyter-launch-from-file-to-url,

update jupyter config file to change #c.NotebookApp.use_redirect_file = True to c.NotebookApp.use_redirect_file = False

alt text