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

Created on 12 Jul 2018  路  9Comments  路  Source: jupyter/notebook

Follow up from https://github.com/jupyter/notebook/pull/3751#issuecomment-404515819:

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.

All 9 comments

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.

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...

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.

(PR #3766 disables the host check for now)

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.

Understood, but I thought https://github.com/jupyter/notebook/pull/3767 was intended to track a longer term fix

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?

It works for me 馃憤

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

Was this page helpful?
0 / 5 - 0 ratings