'Access WSL2 Jupyter notebook remotely

So I'm trying to connect to my jupyter notebook from a remote pc, since my own pc doesn't have a global IP I have to first connect to another pc in the local network(server 1) and then ssh to my own pc with jupyter running on it(server 2) so its something like this:

my laptop -> server 1 -> server 2

I used to do this when both servers were Linux like this:

On my laptop: ssh -NL 2323:localhost:2323 server1_username@golbalIp

On server 1: ssh -NL localhost:2323:localhost:8888 server2_username@localip

On server 2: python3 -m jupyterlab --NotebookApp.token='' --NotebookApp.password='' --port 8888

but now my server 2 is a windows pc and my jupyter is on wls2, so I figured since on windows' localhost:8888 runs wsl2's jupyter then doing the same thing would work but it doesn't, How can I fix this?



Solution 1:[1]

Its not at all obvious, but the solution is that Windows 10 does not like port 8888 and requires you to use 8889 to get the port forwarding to work on WSL2. Took me a long time to work this out. Under native linux there is no issue at all with port, unless the remote host has specific customised firewall rules.

So you must use:

 ssh -NL 8889:localhost:8888 remote-server-alias

where remote-server-alias is something you have defined in your .ssh/config with JumpProxy and you must also have your apache2 server running on your Debian on Windows (WSL2) installation (for example). Check localhost in a browser first to ensure that the apache server is running correctly.

Before you begin you must do the following:

ssh remote-server-alias
nohup jupyter notebook --no-browser --port 8888 &

The token will be stored for you in nohup.out.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eamonn Kenny