Tessa Miller

Oops. You closed out of Chrome and lost all of your precious tabs. Fear not: you can retrieve them. (Probably.) The experts at Stack Exchange are here to help.

I closed Chrome by accident. Now all the tabs I had open are presumably gone. I don't want to risk anything by starting Chrome now before asking for help. I fear that they will be permanently lost (overwritten files) if I do that. I know from past experience with Firefox that restoring tabs and browser sessions can be a tricky business. What can I do at this point? Is there a file or something I need to copy or rename? I know about the Ctrl+Shift+T command, but I normally use this while browsing. Will this work after closing Chrome?

Accidental Closure Prevention

I closed Chrome by accident.

Yes, unfortunately the devs have chosen not to build in a prompt to prevent this. You’ll have to try out some of the extensions that have been written to deal with this and pick one that suits you (unfortunately, due to Chrome’s design, the extensions will need to keep an extra couple of processes running to work).

Data-Loss Prevention

Now all the tabs I had open are presumably gone. I don't want to risk anything by starting Chrome now before asking for help. I fear that they will be permanently lost (overwritten files) if I do that.

Very smart. You are correct that running Chrome will likely wipe them out soon after because it is designed to keep only one set of backups in addition to the current, working copy, so when you start a new instance, it will shift everything back and overwrite the previous one.

I know from past experience with Firefox that restoring tabs and browser sessions can be a tricky business.

It’s not pleasant with Chrome either, but I’ll walk you through the process (I’ve had to do it far too many times).

Session Files

What can I do at this point? Is there a file or something I need to copy or rename?

Copy these four files somewhere so that you can work without losing anything. That way, you can always copy them back if something goes wrong.

Reopen Tab(s)

I know about the Ctrl+T command. But I normally use this while browsing. Will this work AFTER closing Chrome?

Yes, to some degree, however you have the combo wrong. It’s Ctrl+⇧ Shift+T. If you had multiple tabs open before closing it, then it should re-open all of them.

In older versions, for some reason, it would only work if you first created a new tab. I still use Chromium 11 on my XP system and am always baffled by this strange behavior. Whenever I close Chrome accidentally and need to recover my tabs, I first have to open a tab (pressing Ctrl+T for the New Tab Page is easiest) before pressing Ctrl+⇧ Shift+T to get the previous tab(s) back. In newer versions, it works without having to open a tab first.

Now before you go and run Chrome, I have to warn you that it does not always work. First of all, it won’t work immediately after launching Chrome. You have to wait until Chrome reads the user files and parses them. This can take a few moments and you can see it by right-clicking the tab-bar and observing that the Reopen closed tab context-menu entry is grayed/disabled for a while. If you wait a few moments and repeat, it should turn black (enabled) and then you can use it.

However, even if you wait a while, it will not always restore the previous session. Sometimes, Chrome simply loses the previous session and tabs and the reopen-tab function just won’t work. I have not been able to figure out why or discern any sort of pattern or cause, but it always seems to be the case when you need it the most. I haven’t done clinical, experimental tests, but it seems that opening a new tab after launching it is a good way to get Chrome to wipe out your previous session (I guess it figures that you are done with it and starting something new).

In case this ends up happening, I recommend copying the four files above before running Chrome again. That way you won’t lose them if Chrome is in a bad mood and decides to wipe them out. Copy the files, then run Chrome and wait a few moments, then see if reopen-tab is available.

Recovery Mode

If it's still not available, try putting Chrome in recovery mode:

Close Chrome

Copy the backup of the four files back to your User Data directory

Open the Local State file in a text-editor (it is in the parent folder of User Data)

Locate the exited_cleanly entry

Change it to false

Save and exit

Run Chrome

Now it should display the "Chrome didn’t shut down correctly" notice bar. Click the [Restore] button, and hopefully it will restore your session. This should work even if you have opened new tabs before clicking the button.

Manual Extraction

If that still doesn’t work, then you can manually extract the tabs from the files by using a string-searching program like Strings (go figure). Run the program, passing it the files and save them to another file. Most such programs require using the command-line, but presumably there are GUI versions as well (though I can’t seem to find any at the moment). So for example, if you save strings.exe toc:\foobar and copy the four files to there as well, you could extract the tabs as so:

(I added extra spaces to align everything just to make it clear what is happening.) Now you can open the new *tabs.txt text files and see the URLs of the tabs you had open before. Note that you may see a lot of duplication as well as some tabs that you had closed.

The *sess.txt files will contain other information like text that you had typed into forms on a page, so if you had a page open with a bunch of information that you had entered, you can recover that so that you don’t have to start all over again from scratch. (For example, if I accidentally close this page, I could recover this text that I am typing at this very moment instead of trying to do it all again. The horror!)

Note again that you will likely see duplication. The worst part is that if you had been typing something for a while and it has changed numerous times since you started (like this text here), then you will probably find several copies of it, each one a snapshot at different points. This can be tedious to examine each file to see which is the most recent version with the latest changes; but it’s still better than starting over from scratch.

Future Session Management

To avoid having problems like this in the future (and to avoid having to rely on Chrome to work correctly), you can install a session-management extension. There are several to choose from, but I recommend Session Buddy. It works quite well, is versatile, and Hans is receptive to bug-reports and feature-requests. (I think he has recently even added syncing!) Session Buddy will let you manually save a session, but can also automatically save sessions, so you can easily recover from a crash.

Yes, you can! But first things first, copy %LOCALAPPDATA%\Google\Chrome\User Data to a safe location.

Then, start Chrome and right click on the Tab bar and choose Reopen closed tab.

But don't take my word for it. This is guaranteed to work on Chrome version 29.0.1547.57 m. For other versions, check your users manual.

To prevent this problem in the future, change the Chrome settings. Click on the Chrome menu button in the upper right corner of your browser, then click Settings. Where it says "On startup" choose the option Continue where I left off. This way, even if you close Chrome intentionally, when you start it the next time it will show you the tabs you had open previously, for each and every time you close and start it again.

Note however, that unlike Firefox, Chrome will try to load each webpage for each and every open tab. If you have a slow computer or you have many tabs open this could be a problem. It can also affect your bill if you have dial-up connection (let's face it—not every internet user in the world has dedicated Fiber-LAN connection).

Disagree with the answer above? Have your own expertise to contribute? Check out the original post, and see more questions like this at Super User, a question and answer site for computer enthusiasts and power users. And of course, feel free to ask your own question.