Ask Your Question

Sage on Jupyter - socket error

asked 2019-08-09 22:56:52 +0200

Richard_L gravatar image

When I try to start sage with the Jupyter notebook, I get this error:

:~/work> sage -n jupyter
│ SageMath version 8.8, Release Date: 2019-06-26                     │
│ Using Python 2.7.15. Type "help()" for help.                       │
Please wait while the Sage Jupyter Notebook server starts...
[I 13:23:55.592 NotebookApp] Using MathJax: nbextensions/mathjax/MathJax.js
[I 13:23:55.773 NotebookApp] Writing notebook server cookie secret to /run/user/1002/jupyter/notebook_cookie_secret
Traceback (most recent call last):
  File "/home/rllozes/sage-8.8/src/bin/sage-notebook", line 267, in <module>
  File "/home/rllozes/sage-8.8/src/bin/sage-notebook", line 99, in __init__
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/jupyter_core/", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/traitlets/config/", line 657, in launch_instance
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/traitlets/config/", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/notebook/", line 1635, in initialize
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/notebook/", line 1407, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/tornado/", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/rllozes/sage-8.8/local/lib/python2.7/site-packages/tornado/", line 197, in bind_sockets
  File "/home/rllozes/sage-8.8/local/lib/python2.7/", line 230, in meth
    return getattr(self._sock,name)(*args)

socket.error: [Errno 99] Cannot assign requested address

Any idea why I get a socket error?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-08-10 16:44:30 +0200

Richard_L gravatar image

I discovered on StackOverflow that some jupyter installations require specifying the ip address of localhost. So,

sage -n jupyter --ip=

does the trick!

This seems to be a quirk of jupyter, since the classic sage notebook interface finds localhost just fine.

edit flag offensive delete link more


Normally this should not be necessary, but I think on some systems, depending on your permissions, it won't bind to by default.

Iguananaut gravatar imageIguananaut ( 2019-08-14 13:59:59 +0200 )edit

Thanks a lot for the note to start it with sage -n jupyter --ip=

I got "OSError: [Errno 99] Cannot assign requested address", but the same trick worked!

I compiled sage 9.1 with both python 2 and 3, both produce the same error messages. First I had to stumble into the fact that sagenb has been replaced with jupyter - by accident, the transition does not seem to be well documented. Then I found similar hints about the IP on non-sage places which didn't help me since sage -h or -advanced does not list this --ip option.

gg@g gravatar imagegg@g ( 2020-09-15 19:45:41 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-08-09 22:56:52 +0200

Seen: 438 times

Last updated: Sep 15 '20