Visual Studio Code – Fix Hash Sum Mismatch

Yesterday, I did $ sudo apt update and I ended up getting the following error –

Err:25 stable/main amd64 Packages

Hash Sum mismatch

To be honest, I had no idea what does this error even stands for, so I searched for ubuntu apt-update hash sum mismatch fix on google, and got the following results –

One of the users wrote that the easiest fix would be –

$ sudo apt clean
$ sudo apt update

Another fix, according to a user, was to remove the contents of


and run

sudo apt update

A comment on that answer suggested –

If you remove all files, you have to download them again. You can just remove the invalid file to make this process faster.

Part 1

Now, I had two options to fix the issue, but for some reasons, I didn’t want to remove the contents of


so I started with –

sudo apt clean
sudo apt autoclean
sudo apt update

Unfortunately, the solution didn’t work. I was still getting the hash sum mismatch error

Part 2

Removing the contents of /var/lib/apt/lists

Since the source of the problem was Visual Studio Code, it was completely unnecessary to remove all the files. So, I just had to delete the files which were related to vscode –

1 – Search for files

cd /var/lib/apt/lists
ls | grep vs

2 – Enter superuser mode and delete files

sudo su 
cd /var/lib/apt/lists

3 – Clean, remove and update

sudo apt clean && sudo apt autoclean && sudo apt remove && 
sudo apt autoremove && sudo apt update


The problem didn’t disappear.

It was still getting the same error while updating. Only this time, I read the error carefully.

Part 3

This part is all about hit and trial, and trusting my instincts alongside!

Failed to fetch

The above error made me check if Packages.bz2 file exists in /var/lib/apt/lists. So, I checked –

ls /var/lib/apt/lists | grep Packages.bz2

Result – Nothing. Packages.bz2 was missing! Good News?

My initial thought – Add Packages.bz2 to /var/lib/apt/lists and run sudo apt update.

Problem – I had already deleted the two files. –

How to get those files back?

The files available in /var/lib/apt/lists are in the form of site.com_foo_bar_buzz. Now, if you replace _ with /, you’ll get –


will become –

Since two of the files related to VSCode were already gone, I had to download them and put them back to their place. Kudos to history.

history | grep

I also needed the Packages.bz2 file, so I grabbed the downloadable link from the error message.

  • Step 1 – Download the files.
  • Step 2 – Rename files. The name of the files should be similar to the url they were obtained form, except / will be replaced by _. InRelease, Packages, and Packages.bz2 will become –

Now, move those files to /var/lib/apt/lists

sudo su

mv /var/lib/apt/lists
mv /var/lib/apt/lists
mv /var/lib/apt/lists
  • You can move them all together. It doesn’t matter.

Run sudo apt update.

This fixed the whole Hash Sum Mismatch error for me!

I had no idea if it would work or not. I attempted to solve a problem, and everything went fine.



This article was originally posted here!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s