Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid 403: Forbidden Error? #408

Closed
gibbbone opened this issue Jul 30, 2018 · 10 comments · Fixed by jupyter/notebook#3809
Closed

How to avoid 403: Forbidden Error? #408

gibbbone opened this issue Jul 30, 2018 · 10 comments · Fixed by jupyter/notebook#3809

Comments

@gibbbone
Copy link

I'm trying to access the nbdiff-web visualization l but I get a 403 error when I open the URL.

One possible cause maybe that I'm working with Anaconda on a Windows Linux Subsystem. Since the Linux distribution has no browser I usually access notebooks on a localhost port via Chrome from outside the Linux subsystem.

I've tried to do the same with nbdiff-web by adding the following line arguments
--ip localhost -p 8888 --base-url <the folder I'm working>, but with no success.

Is there something else I should try?
Thanks.

@vidartf
Copy link
Collaborator

vidartf commented Jul 31, 2018

I just tested this locally with WSL, and had no problems. What I run is:

nbdiff-web --browser none base_notebook.ipynb [remote_notebook.ipynb]

and then connect to the 127.0.0.1 with the port listed in the output, or use -p to specify the port. The --browser (shorthand -b) option is to prevent WSL from attempting to open a browser.

The --base-url argument should not be needed unless you have a strange network setup, or serving to external users.

@gibbbone
Copy link
Author

I didn't specify the none option for the browser argument, since I thought it was the default in the argparser.

Anyway I did try again with what you suggested and I've got the same error, this is the command line output:

[I nbdimeserver:374] Listening on 127.0.0.1, port 51653
[W webutil:18] No web browser found: could not locate runnable browser.
[I webutil:29] URL: http://127.0.0.1:51653/difftool
[W handlers:443] Blocking request with non-local 'Host' 127.0.0.1 (127.0.0.1:51653). If the notebook should be accessible at that name, set NotebookApp.allow_remote_access to disable the check.
[W log:48] 403 GET /difftool (127.0.0.1) 14.13ms referer=None

Also I forgot to mention that I'm trying to use the tool to check a diff between two of my local commits, i.e:

nbdiff-web --browser none commit_a [commit_b]

I don't know if that may be the problem.

@vidartf
Copy link
Collaborator

vidartf commented Jul 31, 2018

Thanks for including the full log. That warning message is from notebook 5.6 (nbdime reuses some of the notebook server logic). Which python version are you on? And what do you get if you run the following code on the same python that is running nbdime:

import ipaddress
addr = ipaddress.ip_address('127.0.0.1')
print (addr.is_loopback)

@gibbbone
Copy link
Author

I'm on Python 2.7.15 (using a specific conda env) and I get True when I ran the above.

@minrk
Copy link
Member

minrk commented Jul 31, 2018

@giovannibonaccorsi can you connect if you specify 'localhost' instead of '127.0.0.1'? I think this is a bug in the notebook that should be fixed by
jupyter/notebook#3809

@gibbbone
Copy link
Author

gibbbone commented Jul 31, 2018

@minrk I ran again with localhost as ip and I've got the same error.

This is the code:

nbdiff-web --browser none --ip localhost commit_a [commit_b]

And this is the full log:

[I nbdimeserver:374] Listening on 127.0.0.1, port 54771
[W webutil:18] No web browser found: could not locate runnable browser.
[I webutil:29] URL: http://localhost:54771/difftool
[W handlers:443] Blocking request with non-local 'Host' localhost (localhost:54771). If the notebook should be accessible at that name, set NotebookApp.allow_remote_access to disable the check.
[W log:48] 403 GET /difftool (127.0.0.1) 5.81ms referer=None

On the other hand I've got the unicode error you're referring to in 3809 when doing ipaddress.ip_address('127.0.0.1') and I just used a unicode representation. I don't know if that is the cause of my problem.

@vidartf
Copy link
Collaborator

vidartf commented Jul 31, 2018

@giovannibonaccorsi If you feel comfortable with it, would you mind installing the latest version from master (after #409) to ensure that the workaround we put in works for you (both with --ip localhost and without)? A patch release is already long overdue, so it would be nice with a confirmation that this fix works before releasing. The instructions for installing from master is in the README and docs.

@gibbbone
Copy link
Author

gibbbone commented Jul 31, 2018

@vidartf I've time to test the workaround but I need some help with the installation,sorry.
I installed nodejs with conda and tried to run pip install -e git+https://github.com/jupyter/nbdime#egg=nbdime but it aborted at the end. Do I need to run pip from a specific folder?

@gibbbone gibbbone reopened this Jul 31, 2018
@vidartf
Copy link
Collaborator

vidartf commented Aug 1, 2018

I just released a new version, so try installing that instead, and check if it works!

@gibbbone
Copy link
Author

gibbbone commented Aug 2, 2018

@vidartf Hi, I just installed the new version and everything works fine. Thanks a lot for your help!

@vidartf vidartf closed this as completed Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants