Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug port forwarding for using Jupyter notebook remotely

I am trying to use Jupyter notebook on a remote computer. The setup is as follows: I have my home laptop, which can ssh to a specific computer on my university's network (e.g., gateway.myuniv.edu). Once I am logged to gateway.myuniv.edu, I can ssh to the computer on which I would like to run the Jupyter notebook server (e.g. cluster.myuniv.edu).

What works: I can run the server on the gateway and connect to it from my laptop using local port forwarding, as follows:

On gateway.myuniv.edu: $ jupyter notebook --no-browser --port 8888

On my laptop: $ ssh -v -N -L 9000:localhost:8888 [email protected]

Then on my laptop's browser, I open the url: http://localhost:9000

What doesn't work: I don't want to run the server on the gateway, since I can't do heavy computations there. I tried to do the following:

On cluster.myuniv.edu: $ jupyter notebook --no-browser --port 8888

On my laptop: $ ssh -v -N -L 9000:cluster.myuniv.edu:8888 [email protected]

Then on my laptop's browser, I open the url: http://localhost:9000. This doesn't work: SSH says that the connection is refused.

I don't understand why this would happen and how to debug this, would be happy for any help. Thanks!

like image 234
R S Avatar asked Oct 19 '22 04:10

R S


1 Answers

The issue is that you are forwarding port :8888 on cluster.myuniv.edu to port :9000 on gateway.myuniv.edu and then forwarding port :8888 on gateway.myuniv.edu to port 9000 on your laptop.

The solution would the following:

On cluster.myuniv.edu: $ jupyter notebook --no-browser --port 8888

On gateway.myuniv.edu: $ ssh -v -N -L 8888:localhost:8888 [email protected]

On laptop: $ ssh -v -N -L 9000:localhost:8888 [email protected]

I would also recommend that you run Jupyter notebook (on the cluster) and the ssh tunneling (on the gateway) using Tmux or Screen so it remains active even if you close terminal

like image 71
mrandrewandrade Avatar answered Nov 16 '22 08:11

mrandrewandrade