Jupyter notebooks randomly disconnects losing output

Not exactly a fastai question, but I hope you’ll pardon me since fastai is very notebook centric.

I’ve been running into this problem for several weeks now where the notebook would randomly disconnect and I lose all my output. I’m using notebooks from a remote VM, so it’s not local. Based on my understanding, the notebook is expecting a “stream” of data from the remote machine, and if for some reason that gets interrupted, aka disconnect, it just loses all the output.

I can login into the same notebook session and the variables are still live, but I haven’t found a way to recover the output.

Is there anyway to either (i) recover the output from a disconnected notebook session or (ii) just prevent notebooks from disconnecting at random?

And yes, this happens inevitably, sometimes I’ll run stuff for 36hrs without issues other time it dies within an hour. I’ve tried wifi vs wired connection, no difference. Changing VMs don’t help too.