A.I, Data and Software Engineering

Prevent colab from disconnecting with console js


This quick note is one solution (may not optimal) to prevent Colab from disconnecting during training your deep learning model.

disconnect Problem

Recently, my Google Colab notebook often gets disconnected after a while, and the data is lost. I searched and found a solution. So reshare this here.


So to prevent this, we add a JS code to the console. Its purpose is to keep on clicking the page and prevent it from idling. So, I follow these steps:

  • Open the chrome console, Ctrl+ Shift + i to open inspector view
Chrome console
  • Goto console.
Get to the editable area
  • Paste and run the following code in the console:
function ClickConnect(){

And remember to press Enter to start the script, it then can prevent your Colab notebook from disconnecting.

1 comment


A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.