When attempting to launch a Jupyter Notebook I get the following error
$ Jupyter Notebook
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_core/application.py", line 268, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/traitlets/config/application.py", line 663, in launch_instance
app.initialize(argv)
File "</Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/decorator.py:decorator-gen-7>", line 2, in initialize
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/notebook/notebookapp.py", line 1720, in initialize
self.init_webapp()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/notebook/notebookapp.py", line 1482, in init_webapp
self.http_server.listen(port, self.ip)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/tcpserver.py", line 151, in listen
sockets = bind_sockets(port, address=address)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/netutil.py", line 174, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 49] Can't assign requested address
However, when I specify the ip address of 127.0.0.1 (i.e. not 'localhost'), Jupyter Notebook --ip=127.0.0.1
it works perfectly fine.
Also, when I ping localhost it returns that local host is in fact 127.0.0.1.
$ ping localhost
PING localhost.localdomain (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.034 ms
I've checked both etc/hosts and private/etc/hosts, and neither specify a localhost (or anything for that matter).
I am trying to fix this issue as I run Jupyter Notebooks in PyCharm and you can't create a simple shortcut to just run on 127.0.0.1 vice 'localhost'. (No simple shortcut I'm aware of, correct me if I'm wrong) I can launch on 127.0.0.1 in Pycharm, but it takes multiple steps and is burdensome. I just want this to work via its intended configuration of 'localhost' as the default.
Answer credited to @jackw11111
Generate a config file for your jupyter notebook
$ jupyter notebook --generate-config
Jump into this new config file with your favorite editor
$ nano ~/.jupyter/jupyter_notebook_config.py
Add the following line to the file to make this the default server to listen on
c.NotebookApp.ip = '127.0.0.1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With