notebook icon indicating copy to clipboard operation
notebook copied to clipboard

How to solve “forbidden” error in jupyter notebook (conda tab)

Open CorneeldH opened this issue 7 years ago • 47 comments

I installed anaconda and succeeded in making the conda-tab work thanks to the last suggestion in this entry: http://stackoverflow.com/a/41825208/6375668

However, when I try to create an environment or install an additional package I receive a "forbidden" error (see below). When I open anaconda-navigator I am perfectly able to create environments and install packages. In addition, I changed permissions to the anaconda-folders on my Mac and tried starting jupyter with sudo, but that didn't help.

What could be wrong? And how to fix this? Thanks!

"forbidden error"

CorneeldH avatar Apr 11 '17 08:04 CorneeldH

Are you seeing any notebook server errors in the terminal? What version of the notebook and nb-conda are you running?

Here's a similar issue on nb-conda: https://github.com/Anaconda-Platform/nb_conda/issues/44

gnestor avatar Apr 12 '17 06:04 gnestor

Since updating my packages in anaconda (conda update --all) and installing doxygen, I have the same issue. Jupyter will throw the error 403 GET

scaramouche-00 avatar Jan 30 '18 20:01 scaramouche-00

Got the same error. Solved it by opening jupyter in another browser (was using firefox, then used chrome). I think its a "cache" related issue. Maybe someone can explore this futher?

faizankshaikh avatar Feb 17 '18 12:02 faizankshaikh

@faizankshaikh hi, I came to this page because I was having problems saving a notbook while using Firefox. If I use Chrome I don't have any problem, while if I use Firefox I keep getting the "Forbidden" error when I try to save a notebook. I've also tried to disable any extension but it didn't help.

andreagrandi avatar Feb 20 '18 11:02 andreagrandi

#3365 may be related.

takluyver avatar Feb 26 '18 13:02 takluyver

I've fixed one such issue in #3380, if people want to try that. But there may be more than one problem involved; the precise case I hit could only have come up after PR #2959, which was well after the initial report.

takluyver avatar Feb 27 '18 13:02 takluyver

Hello, thanks for this! How can we access the patch? I have anaconda and I have tried updating jupyter (conda update jupyter), but it didn't work (still 403 GET).

scaramouche-00 avatar Feb 27 '18 14:02 scaramouche-00

It will need to be merged and released before you can get it through Anaconda. For a small change like this, it's probably easiest to look at what I've changed, find the matching lines in your installation, and apply the change manually.

Otherwise, you could use git to get it:

git clone https://github.com/takluyver/notebook.git
cd notebook
git checkout i3365
pip install .

The last step needs some Javascript tools (see setting up a development environment).

takluyver avatar Feb 27 '18 15:02 takluyver

Hammering F5 (refresh) seems to be a quickfix for this issue.

thomasaarholt avatar Mar 15 '18 17:03 thomasaarholt

I was having the same 403 status code. The solution was using Jupyter Notebook with Chrome instead of Firefox. I used to blame SELinux configuration.

Here are my details:

OS:

Linux brm10925-pc 4.15.7-300.fc27.x86_64 #1 SMP Wed Feb 28 17:53:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Fedora release 27 (Twenty Seven)

Firefox

58.0.2 (64-bit)

Python

Python 3.6.4

Anaconda

conda 4.3.34

Packages in virtualenv (created with anaconda):

backports                 1.0                      py36_1    conda-forge
backports.functools_lru_cache 1.5                      py36_0    conda-forge
blas                      1.1                    openblas    conda-forge
bleach                    2.1.3                      py_0    conda-forge
bokeh                     0.12.14                  py36_0    conda-forge
ca-certificates           2018.1.18                     0    conda-forge
certifi                   2018.1.18                py36_0    conda-forge
click                     6.7                        py_1    conda-forge
cloudpickle               0.5.2                      py_0    conda-forge
cycler                    0.10.0                   py36_0    conda-forge
cytoolz                   0.9.0.1                  py36_0    conda-forge
dask                      0.17.1                     py_2    conda-forge
dask-core                 0.17.1                     py_0    conda-forge
dbus                      1.10.22                       0    conda-forge
decorator                 4.2.1                    py36_0    conda-forge
distributed               1.21.3                   py36_0    conda-forge
entrypoints               0.2.3                    py36_1    conda-forge
expat                     2.2.5                         0    conda-forge
fontconfig                2.12.6                        0    conda-forge
freetype                  2.8.1                         0    conda-forge
gettext                   0.19.8.1                      0    conda-forge
glib                      2.55.0                        0    conda-forge
gmp                       6.1.2                         0    conda-forge
gst-plugins-base          1.8.0                         0    conda-forge
gstreamer                 1.8.0                         1    conda-forge
heapdict                  1.0.0                    py36_0    conda-forge
html5lib                  1.0.1                      py_0    conda-forge
icu                       58.2                          0    conda-forge
ipykernel                 4.8.2                    py36_0    conda-forge
ipython                   6.2.1                    py36_1    conda-forge
ipython_genutils          0.2.0                    py36_0    conda-forge
ipywidgets                7.1.2                    py36_0    conda-forge
jedi                      0.11.1                   py36_0    conda-forge
jinja2                    2.10                     py36_0    conda-forge
jpeg                      9b                            2    conda-forge
jsonschema                2.6.0                    py36_1    conda-forge
jupyter                   1.0.0                    py36_0    conda-forge
jupyter_client            5.2.3                    py36_0    conda-forge
jupyter_console           5.2.0                    py36_0    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
kiwisolver                1.0.1                    py36_1    conda-forge
libffi                    3.2.1                         3    conda-forge
libgfortran               3.0.0                         1  
libiconv                  1.15                          0    conda-forge
libpng                    1.6.34                        0    conda-forge
libsodium                 1.0.15                        1    conda-forge
libxcb                    1.12                          1    conda-forge
libxml2                   2.9.7                         0    conda-forge
locket                    0.2.0                    py36_1    conda-forge
markupsafe                1.0                      py36_0    conda-forge
matplotlib                2.2.0                    py36_0    conda-forge
mistune                   0.8.3                      py_0    conda-forge
msgpack-python            0.5.5                    py36_0    conda-forge
nbconvert                 5.3.1                      py_1    conda-forge
nbformat                  4.4.0                    py36_0    conda-forge
ncurses                   5.9                          10    conda-forge
notebook                  5.4.0                    py36_0    conda-forge
numpy                     1.14.2          py36_blas_openblas_200  [blas_openblas]  conda-forge
openblas                  0.2.20                        7    conda-forge
openssl                   1.0.2n                        0    conda-forge
packaging                 17.1                       py_0    conda-forge
pandas                    0.22.0                   py36_0    conda-forge
pandoc                    2.1.2                         0    conda-forge
pandocfilters             1.4.1                    py36_0    conda-forge
parso                     0.1.1                      py_0    conda-forge
partd                     0.3.8                    py36_0    conda-forge
patsy                     0.5.0                    py36_0    conda-forge
pcre                      8.41                          1    conda-forge
pexpect                   4.4.0                    py36_0    conda-forge
pickleshare               0.7.4                    py36_0    conda-forge
pip                       9.0.1                    py36_1    conda-forge
prompt_toolkit            1.0.15                   py36_0    conda-forge
psutil                    5.4.3                    py36_0    conda-forge
ptyprocess                0.5.2                    py36_0    conda-forge
pygments                  2.2.0                    py36_0    conda-forge
pyparsing                 2.2.0                    py36_0    conda-forge
pyqt                      5.6.0                    py36_4    conda-forge
python                    3.6.4                         0    conda-forge
python-dateutil           2.7.0                      py_0    conda-forge
pytz                      2018.3                     py_0    conda-forge
pyyaml                    3.12                     py36_1    conda-forge
pyzmq                     17.0.0                   py36_3    conda-forge
qt                        5.6.2                         7    conda-forge
qtconsole                 4.3.1                    py36_0    conda-forge
readline                  7.0                           0    conda-forge
scikit-learn              0.19.1          py36_blas_openblas_201  [blas_openblas]  conda-forge
scipy                     1.0.0           py36_blas_openblas_201  [blas_openblas]  conda-forge
seaborn                   0.8.1                    py36_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                38.5.2                   py36_0    conda-forge
simplegeneric             0.8.1                    py36_0    conda-forge
sip                       4.18                     py36_1    conda-forge
six                       1.11.0                   py36_1    conda-forge
sortedcontainers          1.5.9                    py36_0    conda-forge
sqlite                    3.20.1                        2    conda-forge
statsmodels               0.8.0                    py36_0    conda-forge
tblib                     1.3.2                    py36_0    conda-forge
terminado                 0.8.1                    py36_0    conda-forge
testpath                  0.3.1                    py36_0    conda-forge
tk                        8.6.7                         0    conda-forge
toolz                     0.9.0                      py_0    conda-forge
tornado                   4.5.3                    py36_0    conda-forge
traitlets                 4.3.2                    py36_0    conda-forge
wcwidth                   0.1.7                    py36_0    conda-forge
webencodings              0.5                      py36_0    conda-forge
wheel                     0.30.0                   py36_2    conda-forge
widgetsnbextension        3.1.4                    py36_0    conda-forge
xorg-libxau               1.0.8                         3    conda-forge
xorg-libxdmcp             1.1.2                         3    conda-forge
xz                        5.2.3                         0    conda-forge
yaml                      0.1.7                         0    conda-forge
zeromq                    4.2.3                         2    conda-forge
zict                      0.1.3                      py_0    conda-forge
zlib                      1.2.11                        0    conda-forge

israelzuniga avatar Mar 27 '18 21:03 israelzuniga

@israelzuniga In Firefox, did you try either running Refresh (Ctrl + R or F5) many times after each other, or emptying cache?

thomasaarholt avatar Mar 28 '18 08:03 thomasaarholt

Also check that you haven't disabled cookies - that breaks Jupyter's authentication. But you'll probably know if you've done that.

There's still the fix from #3380 to be released. I'll try to aim for a new release soon.

takluyver avatar Mar 28 '18 08:03 takluyver

@thomasaarholt Yesterday, after getting things done in Chrome, I tried that with good results (emptying cache, and also reinstalling FF). What didn't work so well, was running refresh (a lot of times) from FF without cache deletion. This is at my employers' ThinkPad.

Other times, in my macbook for personal use, I have been using Jupyter/IPython and FF without any issues for years. So, now this is a truly interesting situation.

@takluyver Sure. Even I disabled privacy plugins to discard interferences but was related to FF cache and Jupyer session handling. It works better today.

israelzuniga avatar Mar 28 '18 16:03 israelzuniga

Clearing the cache fixed it for me in Chrome: -Open up Developer Tools and right+click the refresh button -Choose Empty cache and hard reload -Profit!

benelot avatar May 09 '18 09:05 benelot

Thanks for the feedback, @israelzuniga. I oddly didn't see your comment before now.

thomasaarholt avatar May 09 '18 10:05 thomasaarholt

I concur. Firefox is a root cause. I opened with Opera and it is working fine

tolyla25 avatar May 16 '18 01:05 tolyla25

I have this same error, but it's occurring in chrome. Clearing the cache does not help in my case.

New file creation:

Launcher Error
Cannot read property 'path' of undefined

Existing file save after edit Error:

File Save Error for filename.txt
Invalid response: 403 Forbidden

nanodan avatar Jun 26 '18 20:06 nanodan

I've fixed using "sudo jupyter notebook": it requests the password and don't initialise as it does not understand the command, but reinstate the cache access (as it lost privileges for some reason). All works fine after that.

(tensorflow) VirtualBox:~$ sudo jupyter notebook [sudo] password for user: sudo: jupyter: command not found (tensorflow) VirtualBox:~$ jupyter notebook

beraug avatar Jul 14 '18 08:07 beraug

Had this problem today on Chrome. Clearing cache and cookies and then repasting in url with token fixed it.

stephenkrol avatar Jul 25 '18 16:07 stephenkrol

Also check that you haven't disabled cookies - that breaks Jupyter's authentication. But you'll probably know if you've done that.

Yes, it works for me after enabling cookies on Safari.

Manikgarg avatar Jan 08 '19 10:01 Manikgarg

I also experienced this problem. Like many above, I temporarily opened the notebook in chrome, saved it (in chrome), then closed both the chrome + firefox notebooks before restarting the notebook in Firefox w/o issue.

Unsaved code cells within the broken Firefox session were in the chrome notebook so I am assuming that Chrome was able to read the cache contents while Firefox was not, however, since I'm not a jupyter dev take my jump to conclusion here with a grain of salt.

thinkjrs avatar Jan 30 '19 16:01 thinkjrs

I use chrome always, and I get this occassionally. Go your home url (open another tab if necessary) and refresh that page. It will as ask for the authentication token, which can be found in the terminal where the notebook server was started. Once you are logged in (again), go back to your notebook tab and select the "kernel>reconnect" menu item.

rsemenoff avatar Mar 23 '19 19:03 rsemenoff

It worked for me when i changed the browser. :) Before that i struggled for an hour with chrome. I still don't know what is the exact issue with chrome Currently it is working in Mozila firefox

vikash0837 avatar Mar 27 '19 20:03 vikash0837

Thanks all for sharing your solutions! 🙏

gnestor avatar Apr 01 '19 17:04 gnestor

Just try clicking the Jupyter icon in the page.

Shahbaz921 avatar May 10 '19 11:05 Shahbaz921

Your AWS session might have been expired. Just re-login.

vivshri avatar Jun 08 '19 15:06 vivshri

Somehow, I have to re-log in the jupyter session every few days to get over this error.

YubinXie avatar Jul 05 '19 21:07 YubinXie

For get rid of from that error, You have to enable cookies on your browser. Then it will work

kalanaej avatar Nov 29 '19 17:11 kalanaej

I also get this nasty error in chrome all of a sudden (it has been working for months now). If I use Edge, the problem is gone. Has anybody figured what it could be? I tried refreshing, deleting cache, cookies, reentered the token, ...

But still all requests error out with 403, except for the /login page:

[W 15:19:50.801 NotebookApp] 403 GET /api/sessions?_=1576160390722 (::1) 1.99ms referer=http://localhost:8888/tree
[W 15:19:50.802 NotebookApp] Forbidden
[W 15:19:50.802 NotebookApp] 403 GET /api/terminals?_=1576160390723 (::1) 1.99ms referer=http://localhost:8888/tree
[W 15:20:04.664 NotebookApp] Forbidden
[W 15:20:04.670 NotebookApp] 403 GET /api/sessions?_=1576160390724 (::1) 6.98ms referer=http://localhost:8888/tree
[W 15:20:04.675 NotebookApp] Forbidden
[W 15:20:04.676 NotebookApp] 403 GET /api/terminals?_=1576160390725 (::1) 2.00ms referer=http://localhost:8888/tree

Edit: I just realized using the local IP http://127.0.0.1:8888 instead of http://localhost:8888 works for some obscure reasons... At least for me

alxy avatar Dec 12 '19 14:12 alxy

Please enable cookies on your browser to prevent this from happening again

On Thu, 12 Dec 2019 at 19:53, Alexander Guth [email protected] wrote:

I also get this nasty error in chrome all of a sudden (it has been working for months now). If I use Edge, the problem is gone. Has anybody figured what it could be? I tried refreshing, deleting cache, cookies, reentered the token, ...

But still all requests error out with 403, except for the /login page:

[W 15:19:50.801 NotebookApp] 403 GET /api/sessions?=1576160390722 (::1) 1.99ms referer=http://localhost:8888/tree [W 15:19:50.802 NotebookApp] Forbidden [W 15:19:50.802 NotebookApp] 403 GET /api/terminals?=1576160390723 (::1) 1.99ms referer=http://localhost:8888/tree [W 15:20:04.664 NotebookApp] Forbidden [W 15:20:04.670 NotebookApp] 403 GET /api/sessions?=1576160390724 (::1) 6.98ms referer=http://localhost:8888/tree [W 15:20:04.675 NotebookApp] Forbidden [W 15:20:04.676 NotebookApp] 403 GET /api/terminals?=1576160390725 (::1) 2.00ms referer=http://localhost:8888/tree

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jupyter/notebook/issues/2396?email_source=notifications&email_token=AKXIPX3HYMGUI2COMJL7P3DQYJCPDA5CNFSM4DHHCF32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGW2C2Y#issuecomment-565027179, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXIPX7IP23XXRITTAFHLVDQYJCPDANCNFSM4DHHCF3Q .

kalanaej avatar Dec 13 '19 10:12 kalanaej