I have anaconda version 4.9.2 and Jupyter lab version 2.2.9 installed on my Ubuntu 20.10 personal server. Until about two months ago, I was able to remotely start jupyter lab on my remote server (accessed through MobaXterm). I used this command:
jupyter lab --no-browser --port=40000 --ip=$HOSTNAME
I then used to forward this port to a local port 8080 in MobaXterm, and open the local port on my working laptop.
After resetting the whole setup due to a move, I found that I am not able to forward the local port anymore. I get this error message:
Traceback (most recent call last):
File "/home/kvemuri/anaconda3/bin/jupyter-lab", line 10, in <module>
sys.exit(main())
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 254, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 844, in launch_instance
app.initialize(argv)
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in inner
return method(app, *args, **kwargs)
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 2085, in initialize
self.init_webapp()
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 1757, in init_webapp
success = self._bind_http_server()
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 1764, in _bind_http_server
return self._bind_http_server_unix() if self.sock else self._bind_http_server_tcp()
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 1790, in _bind_http_server_tcp
self.http_server.listen(port, self.ip)
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/tornado/tcpserver.py", line 151, in listen
sockets = bind_sockets(port, address=address)
File "/home/kvemuri/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 161, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 22] Invalid argument
I am not too well-versed with the inner workings of port forwarding, I blindly followed the instructions on this page: https://wiki.fysik.dtu.dk/gpaw/summerschools/summerschool18/accesswin.html
The solution in this question provided some clue, but I am not sure how to go about 'binding the socket to a local network interface on same network', if that is even what I need to do. Any thoughts?
Fixed this. The solution was to give a different IP:
jupyter lab --no-browser --ip=0.0.0.0 --port=40000
and then go on to forward the port. I got the idea from here: https://stackoverflow.com/a/57209107/3258696
I don't understand why that works, however, or why jupyter lab --no-browser --ip=127.0.0.1 --port=40000
or jupyter lab --no-browser --ip=127.0.1.1 --port=40000
do not work.
When I do cat /etc/hosts
, I get:
127.0.0.1 localhost
127.0.1.1 kv_home
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Can anybody break down why this error and the fix happened?