Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Creating Notebook failed: FORBIDDEN

I have just upgraded Jupyter to the version 4.3.1 While I can open previously created ipynb files, I cannot create new ones.

When I try to create a new notebook file, I get a pop up windows saying:
Creating Notebook Failed
An error occurred while creating a new notebook
Forbidden

In the terminal I notice this output:

[W 12:53:23.375 NotebookApp] 403 POST /api/contents (::1): '_xsrf' argument missing from POST
[W 12:53:23.383 NotebookApp] 403 POST /api/contents (::1) 8.92ms referer=http://localhost:8888/tree?token=e7fbbb58516dc1359fcc26a1079093166a1f713ee5b94ccd

I use Jupyter with Python 3.5.2 and IPython 5.1.0

like image 282
Mauro Gentile Avatar asked Jan 08 '17 11:01

Mauro Gentile


4 Answers

Another alternative to confirm the issue is to open your Jupyter Session in another browser and you might be redirected to a screen like the following:

enter image description here

If you open a new console and type

jupyter notebook list

You'll see your current notebook and the URL will contain a token. Open that in a new tab and problem solved.

Output command should look like this:

Currently running servers:
http://localhost:8888/?token=cbad1a6ce77ae284725a5e43a7db48f2e9bf3b6458e577bb :: <path to notebook>
like image 141
pablora Avatar answered Oct 11 '22 10:10

pablora


I had to enable cookies in the browser (which I had intentionally disabled). Then the "Forbidden" error disappeared, everything is OK now.

The generally accepted solution to prevent XSRF is to cookie every user with an unpredictable value and include that value as an additional argument with every form submission on your site.

From: http://tornado.readthedocs.io/en/latest/guide/security.html#cross-site-request-forgery-protection

like image 41
Oskar Świerad Avatar answered Oct 11 '22 09:10

Oskar Świerad


Jupyter blocks non-local requests. To access Jupyter from an external address we can execute it with the following parameters:

jupyter notebook --NotebookApp.allow_origin=* --NotebookApp.allow_remote_access=1
like image 2
Freeman Avatar answered Oct 11 '22 09:10

Freeman


I had this problem just now, but I noticed that it worked in Edge. Deleting all browser cache including cookies in Chrome solved this in my case.

like image 1
larslovlie Avatar answered Oct 11 '22 09:10

larslovlie