How to solve Apt-get waiting for headers

Sometimes you play around with some third-party repositories on your Debian-based Linux box, only to find out apt-get hangs while waiting for headers. Really annoying.

You can regenerate the apt-get list cache by executing the following steps.

sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update

That should fix the issue and you should have apt-get update working again. If it did, you can safely remove /var/lib/apt/lists.old/ from your system.