I connect to a remote server using ssh -L
but if I close the laptop lid or the connection is lost, the jupyter notebook is disconnected.
After I reconne
The standard usage for persisting Jupyter server sessions is the use of nohup
and &
; in your remote server with IP address xx.xx.xx.xx
:
nohup jupyter notebook --no-browser --ip xx.xx.xx.xx --port yyyy &
Now, even if you switch off your laptop or lose the connection, you will be always able to reconnect by pointing your browser at xx.xx.xx.xx:yyyy
On the remote server, you should open your jupyter in a screen
session, it will make it persistent if you lose the connection to the server and resume it.
ssh -L xxxx:localhost:yyyy server
.screen
.jupyter notebook --no-browser --port=yyyy
.localhost:xxxx
.To disconnect manually and reconnect:
control + a
and then d
.control + d
ssh -L xxxx:localhost:yyyy
.screen -r
.localhost:xxxx
.Adding to @BiBi's answer...
Instead of screen
I could recommend you to take a look at tmux. Especially, if you combine tmux with the Tmux Plugin Manager and install Tmux Resurrect, even after reboots of your remote server you will be able to go back to your previous Tmux sessions.
Shortcuts for tmux are somewhat equal to those of screens, just that control + a
is replaced by control + b
. Of course, tmux allows you to configure your custom shortcuts.