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

"ValueError: 'fe80::1%lo0' does not appear to be an IPv4 or IPv6 address" error when running notebook #3754

Closed
gnestor opened this issue Jul 12, 2018 · 9 comments

Comments

@gnestor
Copy link
Contributor

gnestor commented Jul 12, 2018

Follow up from #3751 (comment):

I'm getting a strange error when trying to run the notebook against master:

$ jupyter notebook
[W 13:07:55.769 NotebookApp] server_extensions is deprecated, use nbserver_extensions
[I 13:07:55.804 NotebookApp] It looks like you're running the notebook from source.
        If you're working on the Javascript of the notebook, try running
    
        npm run build:watch
    
        in another terminal window to have the system incrementally
        watch and build the notebook's JavaScript for you, as you make changes.
Traceback (most recent call last):
  File "/Users/grant/anaconda/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'allow_remote_access'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/grant/Sites/jupyter/notebook/notebook/notebookapp.py", line 856, in _default_allow_remote
    addr = ipaddress.ip_address(self.ip)
  File "/Users/grant/anaconda/lib/python3.6/ipaddress.py", line 54, in ip_address
    address)
ValueError: 'localhost' does not appear to be an IPv4 or IPv6 address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/grant/anaconda/bin/jupyter-notebook", line 11, in <module>
    load_entry_point('notebook', 'console_scripts', 'jupyter-notebook')()
  File "/Users/grant/anaconda/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/grant/anaconda/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/Users/grant/anaconda/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Users/grant/Sites/jupyter/notebook/notebook/notebookapp.py", line 1598, in initialize
    self.init_webapp()
  File "/Users/grant/Sites/jupyter/notebook/notebook/notebookapp.py", line 1350, in init_webapp
    self.jinja_environment_options,
  File "/Users/grant/Sites/jupyter/notebook/notebook/notebookapp.py", line 158, in __init__
    default_url, settings_overrides, jinja_env_options)
  File "/Users/grant/Sites/jupyter/notebook/notebook/notebookapp.py", line 256, in init_settings
    allow_remote_access=jupyter_app.allow_remote_access,
  File "/Users/grant/anaconda/lib/python3.6/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/Users/grant/anaconda/lib/python3.6/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/Users/grant/Sites/jupyter/notebook/notebook/notebookapp.py", line 863, in _default_allow_remote
    if not ipaddress.ip_address(addr).is_loopback:
  File "/Users/grant/anaconda/lib/python3.6/ipaddress.py", line 54, in ip_address
    address)
ValueError: 'fe80::1%lo0' does not appear to be an IPv4 or IPv6 address

According to @takluyver, likely related to #3714:

For some reason it seems to be determining that localhost resolves to 'fe80::1%lo0', which isn't a valid IP address.

@gnestor gnestor added this to the 5.6 milestone Jul 12, 2018
@takluyver
Copy link
Member

Can you check the output of:

import socket
socket.getaddrinfo('localhost', 8888, 0, socket.SOCK_STREAM)

Is that address in there? If so, can you figure out where it's coming from? E.g. is it in /etc/hosts?

If we can't figure this out quickly, or if it looks like this might be a more common problem for mac users, we can disable the check by default for the 5.6 release and debug it more afterwards.

@gnestor
Copy link
Contributor Author

gnestor commented Jul 13, 2018

Here is the output that I get when running 5.5.0 (because I can't actually start the notebook server on master):

[(<AddressFamily.AF_INET6: 30>,
  <SocketKind.SOCK_STREAM: 1>,
  6,
  '',
  ('::1', 8888, 0, 0)),
 (<AddressFamily.AF_INET6: 30>,
  <SocketKind.SOCK_STREAM: 1>,
  6,
  '',
  ('fe80::1%lo0', 8888, 0, 1)),
 (<AddressFamily.AF_INET: 2>,
  <SocketKind.SOCK_STREAM: 1>,
  6,
  '',
  ('127.0.0.1', 8888))]

The top of my /etc/hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
fe80::1%lo0	localhost

That's macOS defaults...

@takluyver
Copy link
Member

OK, if this is going to affect lots of Mac users, let's disable the check, do a release, and try to figure it out for 5.7.

Can you investigate more what this 1%lo0 means? I suspect lo stands for loopback, but I've never seen that syntax before, and I don't know how our code should be handling it.

takluyver added a commit to takluyver/notebook that referenced this issue Jul 14, 2018
@takluyver
Copy link
Member

(PR #3766 disables the host check for now)

@takluyver
Copy link
Member

Thanks, but it was a workaround, not a fix. I still want to investigate this and find a proper fix so we can have the check enabled by default.

@takluyver takluyver reopened this Jul 14, 2018
@gnestor
Copy link
Contributor Author

gnestor commented Jul 14, 2018

Understood, but I thought #3767 was intended to track a longer term fix

@takluyver
Copy link
Member

I've just done some reading and the %lo0 is a 'zone identifier'. fe80::1 is a link-local address, and the zone identifier scopes it to only the loopback interface. I've updated #3767 - can you try with that?

@gnestor
Copy link
Contributor Author

gnestor commented Jul 16, 2018

It works for me 👍

@takluyver
Copy link
Member

Thanks. Let's land that again and see how it goes in master, then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants