Every once in awhile my jupyter notebook has this popup, and I won’t be able to run anything at all:
“A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.”
My ubuntu terminal shows: “Connection reset by $ip Port 22”.
Whenever this happens in the middle of model training, I basically will have to restart everything, and it is becoming quite frustrating. I noticed that this problem occurs very frequently when I’m using a home network, but it seems to be fine when I’m using a public network (library etc.). I’m currently using an aws p2 instance (fastai AMI)
Has anyone encountered this problem before and found a solution to it? Really appreciate the help, thanks in advance!
This is a common problem and might be because you are running Jupyter Notebook from the terminal of the remote machine. You need to install tmux -
apt-get install tmux, then start the Jupyter Notebook inside the tmux session. That way even if your SSH connection to the remote machine gets disconnected, the tmux session is still running remotely that will keep your Jupyter session active and running.
You can then re-connect (ssh) to the machine again and type
tmux a (attach) to the running session. There are lots of great tutorials on Tmux. This one might be a good place to start - https://hackernoon.com/a-gentle-introduction-to-tmux-8d784c404340
@ramesh Awesome Ramesh! Trying it now and hopefully all goes well. Thank you so much for your help!
@ramesh I’ve just encountered the same problem again, I lost my ssh connection from within my tmux session which meant that I had to re-run jupyter notebook and my models again etc.
This is how I understand it should be done,please let me know if I got any of the steps wrong:
- open ubuntu terminal, ssh into my aws instance
ssh ubuntu@$ip -L8888:localhost:8888
- From within my remote instance, open new tmux session with
$ tmux new
- run jupyter notebook
$ jupyter notebook and connect to port 8888 via browser (localhost:8888).
When the error occurs again (Connection has been reset by $ip port 22), what do I do? What I usually do is that I ssh in again and have to run
$ jupyter notebook and then access
localhost:8888 via my browser, from which I’ll have to navigate to my jupyter notebook from the root directory and re-run it. Pretty sure there must be something that I’m doing wrong here.
Thanks for the help Ramesh!
Yeah…If you do tunneling it would be a problem if you loose the ssh connection. I usually open the port in AWS or the cloud machine. Then just access it via
<ip address of remote machine>:8888
That way you can avoid the issue of tunneling via localhost. Alternatively you can look at how you can keep SSH connection long running. But i don’t have any thoughts on it.
Hello. My contribution to solve the ssh “connection reset by $ip port 22” problem.