28

Trying to run jupyter notebook on a CentOS 7. It comes back with:

OSError: [Errno 99] Cannot assign requested address

And the stack trace:

[user@desktop ~]$ jupyter notebook
Traceback (most recent call last):
  File "/home/use/anaconda3/bin/jupyter-notebook", line 6, in <module>
    sys.exit(notebook.notebookapp.main())
  File "/home/user/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/user/anaconda3/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 "/home/user/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize
    self.init_webapp()
  File "/home/user/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1120, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/home/user/anaconda3/lib/python3.6/site-packages/tornado/tcpserver.py", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/user/anaconda3/lib/python3.6/site-packages/tornado/netutil.py", line 197, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address
Zahra
  • 6,798
  • 9
  • 51
  • 76
  • 1
    `jupyter notebook --ip=127.0.0.1 --port=8888` got things going for me. the error was likely caused because the default ip/port that it was previously trying to assign was already taken. – Zahra May 16 '18 at 15:25

4 Answers4

38
jupyter notebook --ip=127.0.0.1 --port=8888

I had to simply set the ip/port params. The issue was likely caused because the default ip/port that it was previously trying to assign was already taken!

Zahra
  • 6,798
  • 9
  • 51
  • 76
6

In a remote VM, I solved the issue by

$ jupyter-notebook --ip=0.0.0.0 --port=8888
...
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://0.0.0.0:8888/?token=1234567890abcdefghijklmnopqrstuvwxyz  (the token is for demo)
    
...

Note: do not assign the specific ip

then I can connect to jupyter notebook via:

http://your_vm_ip:8888/?token=1234567890abcdefghijklmnopqrstuvwxyz

(replace 0.0.0.0 with your_vm_ip)

enter image description here

蔡宗容
  • 927
  • 12
  • 9
1

Here is a permanent solution.

  1. Create a configuration file for Jupyter, enter in the terminal: jupyter notebook --generate-config
  2. The last command will create a file in /home/USER/.jupyter/jupyter_notebook_config.py
  3. Open the file jupyter_notebook_config.py and edit the variable c.NotebookApp.ip as follows:
    # c.NotebookApp.ip = 'localhost'
    c.NotebookApp.ip = '127.0.0.1'
  4. Enter in the terminal: jupyter notebook

Remarks: sometimes need to first chmod to grant permissions, the file

Loich
  • 813
  • 11
  • 18
0

If you've tried several ports already (using --port XXXX), and none work:

Check that the localhost entry in /etc/hosts/ is not set to something other than 127.0.0.1.

ELinda
  • 2,658
  • 1
  • 10
  • 9