How to stop Colab from disconnecting? — 2021 Solution

Maneesh Mohan
1 min readMar 4, 2021

The main problem people were facing while working with google Colab is

If you are not interacting with notebook for more than 90 minutes, its runtime is automatically disconnected.

Photo by Aarón Blanco Tejedor on Unsplash

The only solution to this is you should interact with notebook in regular intervals but this is not always possible. In this kind of situation it will be easy to write some code in the browser console which makes the environment active throughout your process.

Open Browser Console

ctrl + shift + i or Press F12

The browser developer tools will get open after that use the following procedure to open the console.

Click on console or Press ESC

Paste the following code in the console and hit Enter.

function ClickConnect(){
console.log("Working");
document.querySelector("colab-toolbar-button#toolbar-add-code").click()
}setInterval(ClickConnect,120000)

It will insert the code cell in the regular intervals. You can change the interval time according to your wish. The below code will be useful for inserting text cell in regular intervals.

function ClickConnect(){
console.log("Working");
document.querySelector("colab-toolbar-button#toolbar-add-text").click()
}setInterval(ClickConnect,120000)

This technique will surely help you from colab runtime disconnection.

--

--

Maneesh Mohan

Machine learning Engineer,Computer Vision Enthusiast, Researcher