Notebook: ValueError: '' does not appear to be an IPv4 or IPv6 address

Created on 20 Sep 2018  Â·  12Comments  Â·  Source: jupyter/notebook

might be related to #3754

I'm running jupyter notebook on an EMR cluster

$ jupyter notebook --version
5.7.0
$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost6 localhost6.localdomain6

Most helpful comment

It seems the error appears when you have

c.NotebookApp.ip = '*'

into your jupyter_notebook_config.py.

Replacing * by 0.0.0.0 worked for me.

c.NotebookApp.ip = '0.0.0.0'

All 12 comments

I got the same error when I upgraded jupyterlab to 0.34.11, and finally found that it's a notebook problem.
I upgraded jupyterlab by

sudo -H pip install -U --force-reinstall jupyterlab

It would upgrade and reinstall all required packages by jupyterlab thus including notebook.

Actually, I had three tracebacked errors when running jupyter lab

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 869, in _default_allow_remote
addr = ipaddress.ip_address(self.ip)
File "/usr/lib/python3.6/ipaddress.py", line 54, in ip_address
address)
ValueError: '' 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 "/usr/local/bin/jupyter-lab", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/jupyter_core/application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, *kwargs)
File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "", line 2, in initialize
File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, *
kwargs)
File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 1629, in initialize
self.init_webapp()
File "/usr/local/lib/python3.6/dist-packages/jupyterlab/labapp.py", line 202, in init_webapp
super().init_webapp(args, *kwargs)
File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 1379, in init_webapp
self.jinja_environment_options,
File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 158, in __init__
default_url, settings_overrides, jinja_env_options)
File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 251, in init_settings
allow_remote_access=jupyter_app.allow_remote_access,
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 872, in _default_allow_remote
for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

It seems like all errors related to notebook.

System info:

Ubuntu 16.04.5 LTS
python 3.6.6
jupyterlab 0.34.11
notebook 5.7.0

BTW, I also upgraded jupyterlab at same way in my MacBook Pro (which installed python 3.6.5), it works fine!

Pretty sure this is a problem with the 5.7.0 release. Downgrading notebook to 5.6.0 worked for me.

pip uninstall notebook
pip install notebook==5.6.0

It seems the error appears when you have

c.NotebookApp.ip = '*'

into your jupyter_notebook_config.py.

Replacing * by 0.0.0.0 worked for me.

c.NotebookApp.ip = '0.0.0.0'

Can confirm the described problem and @batmorell ‘s fix.
This is probably a result of #3767 (and this did came from #3754).

I am not sure if it is intended that c.NotebookApp.ip = '*' is not working any more, but documentation still says that is is valid (I am not sure if this are all places of the documentation):

https://github.com/jupyter/notebook/blob/775cb20de3dc273f1fc31cd55d895e16dfe98bdf/docs/source/public_server.rst#L215-L216

https://github.com/jupyter/notebook/blob/775cb20de3dc273f1fc31cd55d895e16dfe98bdf/docs/source/public_server.rst#L254-L255

This briefly broke TensorFlow's Release + Nightly CI, and was fixed with @batmorell's suggestion in https://github.com/tensorflow/tensorflow/pull/22451. Thanks!

  • When I run jupyter notebook in the AWS E2,it also has error as follow:
ubuntu@ip-172-31-48-131:~$ jupyter notebook --no-browser --port=8888
[I 00:41:44.556 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/note
book_cookie_secret
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 869, in _default_al
low_remote
    addr = ipaddress.ip_address(self.ip)
  File "/usr/lib/python3.6/ipaddress.py", line 54, in ip_address
    address)
ValueError: '' 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 "/usr/local/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/jupyter_core/application.py", line 266, in launch_
instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 657, in lau
nch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 87, in catc
h_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 1629, in initialize

    self.init_webapp()
  File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 1379, in init_webap
p
    self.jinja_environment_options,
  File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 158, in __init__
    default_url, settings_overrides, jinja_env_options)
  File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 251, in init_settin
gs
    allow_remote_access=jupyter_app.allow_remote_access,
  File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/usr/local/lib/python3.6/dist-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/usr/local/lib/python3.6/dist-packages/notebook/notebookapp.py", line 872, in _default_al
low_remote
    for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
  • My system info
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
  • My jupyter_notebook_config.py file which at ~/.jupyter/jupyter_notebook_config.py
c = get_config()  # Get the config object.
c.NotebookApp.certfile = u'/home/ubuntu/ssl/cert.pem' # path to the certificate we generated
c.NotebookApp.keyfile = u'/home/ubuntu/ssl/cert.key' # path to the certificate key we generated
c.NotebookApp.ip = '*'  # Serve notebooks locally.
c.NotebookApp.open_browser = False  # Do not open a browser window by default when using notebooks.
c.NotebookApp.password = 'sha1:fc216:3a35a98ed980b9...'  
  • Solvetion: after replacing * by 0.0.0.0 ,everything works.
//at ~/.jupyter/jupyter_notebook_config.py
//change c.NotebookApp.ip = '*' to
c.NotebookApp.ip = '0.0.0.0'

Another workaround while leaving c.NotebookApp.ip='*' is to also set c.NotebookApp.allow_remote_access=True.

Would the devs be open to a short-circuit in NotebookApp._default_allow_remote checking for a blank self.ip (the '*' is stripped in NotebookApp.valdate_ip [sic]) and returning True before checking things with the socket/ipaddress stuff? By the documentation, the '*' value is meant for public server use.

'*' is getting converted to '' by this code:

https://github.com/jupyter/notebook/blob/04a686dbaf9dfe553324a03cb9e6f778cf1e3da1/notebook/notebookapp.py#L660-L665

PRs welcome to special case the empty string in the code checking for allow_remote_access.

'0.0.0.0' would break ipv6. For ipv6 please use '::' instead
Hope this will be helpful to those who are using ipv6

You could even simply run your command with the change:

docker run -p 8888:8888 [container name] jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser --allow-root

Notice I change --ip='*' to --ip='0.0.0.0'

Hi I have changed it to 0.0.0.0 it's still not working

[nb_conda_kernels] enabled, 1 kernels found
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/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 "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/notebook/notebookapp.py", line 864, in _default_allow_remote
    addr = ipaddress.ip_address(self.ip)
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/ipaddress.py", line 54, in ip_address
    address)
ValueError: '' 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 "/home/ubuntu/anaconda3/envs/fastai/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/notebook/notebookapp.py", line 1628, in initialize
    self.init_webapp()
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/notebook/notebookapp.py", line 1378, in init_webapp
    self.jinja_environment_options,
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/notebook/notebookapp.py", line 159, in __init__
    default_url, settings_overrides, jinja_env_options)
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/notebook/notebookapp.py", line 252, in init_settings
    allow_remote_access=jupyter_app.allow_remote_access,
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/site-packages/notebook/notebookapp.py", line 867, in _default_allow_remote
    for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
  File "/home/ubuntu/anaconda3/envs/fastai/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

I have using ec2 amazon instance

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

$ which jupyter
/home/ubuntu/anaconda3/envs/fastai/bin/jupyter

'0.0.0.0' would break ipv6. For ipv6 please use '::' instead
Hope this will be helpful to those who are using ipv6

if i use simultaneously ipv6 and ipv4?

Was this page helpful?
0 / 5 - 0 ratings