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

Socket Error 99 for ipython notebook #6193

Closed
gluincth opened this issue Jul 23, 2014 · 13 comments
Closed

Socket Error 99 for ipython notebook #6193

gluincth opened this issue Jul 23, 2014 · 13 comments
Milestone

Comments

@gluincth
Copy link

@gluincth gluincth commented Jul 23, 2014

Hi
when trying to open a notebook I get a socket error 99 "Cannot assign requested address". This happened after a system update, although Ipython was updated only from 2.1.0-62 to 2.1.0-63 (SuSE package) I checked the following without any sucess:

  1. checked if loopback device is running (it is with inet addr:127.0.0.1 Mask:255.0.0.0)
  2. checked with netstat -lp if standard port is already assigned (it was not)
  3. run a small test script to start tornado web server at port 8888, it worked
  4. Create a default profile and run ipython again
  5. Started ipython with explicit host and (random) port (ipython notebook --init --ip='localhost' --port=49151)
  6. Tried is as root
  7. Checked that the firewall is not blocking
  8. Checked that I am able to write to tmp (in case that is needed)

So I am at a loss what else I can do. Any pointer on what else I can do are appreciated.

The start-up message is
tmp/> ipython notebook --init --log-level=50 --ip='localhost' --port=49151 [15:46:39]
Traceback (most recent call last):
File "/usr/bin/ipython", line 5, in
start_ipython()
File "/usr/lib/python2.7/site-packages/IPython/init.py", line 120, in start_ipython
return launch_new_instance(argv=argv, *_kwargs)
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 563, in launch_instance
app.initialize(argv)
File "", line 2, in initialize
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, *args, *_kwargs)
File "/usr/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 320, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "", line 2, in initialize
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 381, in initialize
self.parse_command_line(argv)
File "/usr/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 315, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "", line 2, in parse_command_line
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 475, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "", line 2, in initialize_subcommand
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 413, in initialize_subcommand
self.subapp.initialize(argv)
File "", line 2, in initialize
File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 745, in initialize
self.init_webapp()
File "/usr/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 632, in init_webapp
self.http_server.listen(port, self.ip)
File "/usr/lib64/python2.7/site-packages/tornado/tcpserver.py", line 116, in listen
sockets = bind_sockets(port, address=address)
File "/usr/lib64/python2.7/site-packages/tornado/netutil.py", line 103, in bind_sockets
sock.bind(sockaddr)
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 99] Cannot assign requested address

My system configuration is
{'commit_hash': '681fd77',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/usr/lib/python2.7/site-packages/IPython',
'ipython_version': '2.1.0',
'os_name': 'posix',
'platform': 'Linux-3.11.10-17-default-x86_64-with-SuSE-13.1-x86_64',
'sys_executable': '/usr/bin/python',
'sys_platform': 'linux2',
'sys_version': '2.7.6 (default, Nov 21 2013, 15:55:38) [GCC]'}

My tornado version is
Name: python-tornado/Version: 3.2.1-2.1/Arch: x86_64

@minrk
Copy link
Member

@minrk minrk commented Jul 23, 2014

And what if you try --ip=127.0.0.1?

@gluincth
Copy link
Author

@gluincth gluincth commented Jul 24, 2014

Hi

That works (should have thought of that). I put it into my ipython_notebook_config.py. I wonder though why the behaviour changed...
So from my side I could close this issue. Only if one could change the error message to something meaningful that points to the solution, I would keep this issue open. But maybe this problem is too specific...

Thanks a lot for the quick answer!

@minrk
Copy link
Member

@minrk minrk commented Jul 24, 2014

Copying explanation from #6191:

IPython listens on localhost by default. 127.0.0.1 ought to behave the same, and does in almost all cases. Some cases where this can be handled differently include local proxies and/or firewalls (usually due to a configuration oversight, rather than an intentional difference in behavior). We have found cases where localhost works and 127 doesn't and vice versa, so there isn't an unambiguously correct answer for the default.

Do you have a firewall and/or proxy configuration? If so, do you control its configuration? I would describe this behavior as a bug in your network setup, but it may not be one that you have permission to fix.

@minrk minrk closed this Jul 24, 2014
@minrk minrk added this to the no action milestone Jul 24, 2014
@naoko
Copy link

@naoko naoko commented Aug 17, 2014

Thank you, specifying 127.0.0.1 solved the socket error for me as well

@tigerneil
Copy link

@tigerneil tigerneil commented Dec 11, 2017

If you use it in cloud server, you can use --ip=0.0.0.0.

@Leegenux
Copy link

@Leegenux Leegenux commented Jan 23, 2018

Thanks for keeping this issue on, I am setting up a notebook server on a cloud server. And specifying the listening ip as "0.0.0.0" does solved this same problem.

@OussamaSegh
Copy link

@OussamaSegh OussamaSegh commented Oct 23, 2018

Thanks, I had the same problem :)

etejedor added a commit to etejedor/root that referenced this issue Nov 23, 2018
Users might want to connect to a notebook server launched with
'root --notebook' from another computer. This setting of the
Jupyter configuration makes that possible.

This also solves the issue explained here:

ipython/ipython#6193

Depending on the network configuration of a machine/container,
binding on localhost might fail. This looks like the issue
reported on ROOT-9829.
etejedor added a commit to etejedor/root that referenced this issue Nov 23, 2018
Users might want to connect to a notebook server launched with
'root --notebook' from another computer. This setting of the
Jupyter configuration makes that possible.

This also solves the issue explained here:

ipython/ipython#6193

Depending on the network configuration of a machine/container,
binding on localhost might fail. This looks like the issue
reported on ROOT-9829.
etejedor added a commit to root-project/root that referenced this issue Nov 27, 2018
Users might want to connect to a notebook server launched with
'root --notebook' from another computer. This setting of the
Jupyter configuration makes that possible.

This also solves the issue explained here:

ipython/ipython#6193

Depending on the network configuration of a machine/container,
binding on localhost might fail. This looks like the issue
reported on ROOT-9829.
etejedor added a commit to etejedor/root that referenced this issue Nov 27, 2018
Users might want to connect to a notebook server launched with
'root --notebook' from another computer. This setting of the
Jupyter configuration makes that possible.

This also solves the issue explained here:

ipython/ipython#6193

Depending on the network configuration of a machine/container,
binding on localhost might fail. This looks like the issue
reported on ROOT-9829.
etejedor added a commit to root-project/root that referenced this issue Nov 28, 2018
Users might want to connect to a notebook server launched with
'root --notebook' from another computer. This setting of the
Jupyter configuration makes that possible.

This also solves the issue explained here:

ipython/ipython#6193

Depending on the network configuration of a machine/container,
binding on localhost might fail. This looks like the issue
reported on ROOT-9829.
@Chichilele
Copy link

@Chichilele Chichilele commented Dec 13, 2018

thanks it solved it !

alja added a commit to alja/root that referenced this issue Dec 21, 2018
Users might want to connect to a notebook server launched with
'root --notebook' from another computer. This setting of the
Jupyter configuration makes that possible.

This also solves the issue explained here:

ipython/ipython#6193

Depending on the network configuration of a machine/container,
binding on localhost might fail. This looks like the issue
reported on ROOT-9829.
@mlazowik
Copy link

@mlazowik mlazowik commented Feb 21, 2019

For people coming from search results: check your /etc/hosts for typos and ipv6 config. localhost should only point to ipv4 loopback (127.0.0.1), not to ipv6 (::1). This can break other stuff, not only jupyter.

For example, this is wrong:
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
this is ok:
::1 localhost6 localhost6.localdomain6

codenvy/codenvy#2427 (comment)
https://bugzilla.redhat.com/show_bug.cgi?id=211800#c4

@craymichael
Copy link

@craymichael craymichael commented Jul 3, 2019

@mlazowik Thanks a lot! This resolved my issue - I wonder how many others have this same issue but have opted for the 127.0.0.1 solution. This is the correct solution (ensuring the hostname lookup table is correct). In my instance (Arch Linux), my /etc/hosts was "shipped" as follows:

127.0.0.1       localhost.localdomain    localhost
::1             localhost.localdomain    localhost

And I corrected it to the following:

127.0.0.1       localhost.localdomain    localhost
::1             localhost6.localdomain6  localhost6 
@0xfeedbac
Copy link

@0xfeedbac 0xfeedbac commented Sep 3, 2019

If you use it in cloud server, you can use --ip=0.0.0.0.

For me (on mac) only the --ip=0.0.0.0 works the local running docker.

@liho98
Copy link

@liho98 liho98 commented Dec 14, 2019

For my case, it is due to the /etc/hosts for duplicated ::1 loopback address in IPv6.
After commented out the second loopback address ::1, the error is gone.

Screenshot from 2019-12-14 16-32-13

@jwhendy
Copy link

@jwhendy jwhendy commented Jan 6, 2020

@mlazowik I had the same problem with the same eventual solution, but found it interesting that man /etc/hosts has this in their example, which kept me from figuring out my issue (as a presumed authority recommends exactly what you're saying is problematic):

# The following lines are desirable for IPv4 capable hosts
127.0.0.1       localhost
127.0.1.1       thishost.mydomain.org  thishost

[...]

# The following lines are desirable for IPv6 capable hosts
::1             localhost ip6-localhost ip6-loopback

I dropped the localhost from the ::1 entry (keeping the other two) and all is good. I also assumed ip6 was an ipv6 keyword, but perhaps ip6-foo and foo6 are both fine (e.g. just some form of name mangling vs. the ipv4 equivalent)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet