8

I am having what seems to be a perennial problem with JupyterLab users but when applying the solutions that have worked with others, I am not getting positive results.

This problem is new, only emerging over the past few weeks.

This problem is occurring only with JupyterLab (not Jupyter Notebook) for ...

  • Operating System: macOS-11.4-x86_64-i386-64bit
  • Miniconda Build: 4.10.1
  • Python Version: 3.8.10
  • Browsers:
    • Safari for MacOS 14.1.1 (16611.2.7.1.4)
    • Chrome for MacOS 91.0.4472.77 (Official Build) (x86_64)
  • Jupyter Suite Versions:
    • jupyter 1.0.0
    • jupyter-client 6.1.12
    • jupyter-console 6.4.0
    • jupyter-core 4.7.1
    • jupyter-server 1.8.0
    • jupyterlab 3.0.16
    • jupyterlab-pygments 0.1.2
    • jupyterlab-server 2.5.2
    • jupyterlab-widgets 1.0.0

Problem:

When working with a locally-run JupyterLab (i.e., using a URL of 128.0.0.1:8888, or localhost:8888), when Exporting a IPYNB notebook to HTML, txt or other format, I get the following two errors:

[W 2021-05-27 14:50:15.795 ServerApp] Blocking request with no referer
[W 2021-05-27 14:50:15.795 ServerApp] 403 GET /nbconvert/html/Untitled.ipynb?download=true (::1): Blocking request from unknown origin

However, when using the same IPYNB notebook (even one simply consisting of a single cell saying print("hello"), in a basic Jupyter Notebook session the exports function satisfactorily and create nice viewable HTML and PDF files.

I have search across solution resources and the closet thing I've seen for guidance has been to add the change two lines in the jupyter configuration files as so:

c.NotebookApp.allow_origin=''
c.NotebookApp.allow_remote_access = True

I have tried this on more than one fresh install of Minconda and this does not yield favorable results. (Some of these recommendations are coming for users of JupyterHub, not JupyterLab).

I have a "gist" from a sample JupyterLab session available showing both

  • the debug log of the specific problem if a notebook with the single cell containing "print('Hello')"
  • the output of the jupyter troubleshoot command showing the configuration of my miniconda/python/jupyter setup.

https://gist.github.com/wjcapehart/a6145ae8e7e1f967bab7412fd118c455 (my username is replaced with ${HOME} in the Gist files.)

Does anyone have any ideas here?

Cheers and Thanks Bill

Bill Capehart
  • 85
  • 1
  • 5

2 Answers2

2

Issue jupyterlab #7539 may be related. In the meantime, you might want to try Firefox as a workaround. It seems that Chrome (and probably Safari and others) are not a sending Referer header, and that is causing the problem.

I am experiencing the same problem with a JupyterLab instance with a domain (unlike your local install). And I can confirm that Firefox works.

M. Zhang
  • 750
  • 8
  • 18
2

Setting c.ServerApp.disable_check_xsrf = True in jupyter_server_config.py fixed the errors "Blocking request from unknown origin" and "Blocking request with no referer" when using Safari with a localhost instance of jupyter-lab (3.1.7).

To determine where jupyter config files are located use the command

$ jupyter-lab --paths

Then generate a default config which has all default values commented out

$ jupyter-lab server --generate-config

Add the config change (note the comment regarding the security warning)

c.ServerApp.disable_check_xsrf = True

Verify the current config.

$ jupyter-lab --show-config

Hopefully this helps others.

  • Note that there is also a command-line option for Jupyter for this, like so `jupyter notebook --NotebookApp.extra_static_paths="$PWD"/ --notebook-dir "$PWD" --NotebookApp.disable_check_xsrf=True`` – Martin Hepp Sep 26 '22 at 15:18