Stuck at 0% [waiting for headers]

Try to change the server selecting update manager, definitions,downloading from, then select a server more near you. and then try again.

Edit: see this link on how to add it by editing sources.list. How can I get apt to use a mirror close to me, or choose a faster mirror?


The easiest approach consist of following commands:

sudo apt-get clean

&

sudo apt-get update

then

sudo apt-get install <package_name>

Cheers

Let me know if it works


I had to

sudo apt-key update
sudo apt-get update

From manpages:

apt-key is used to manage the list of keys used by apt to authenticate packages. Packages which have been authenticated using these keys will be considered trusted.


If you are using a proxy server and have those settings in your user environment, try:

sudo -E apt update

to run the command as root but using your current user's environment.


(Just reposting this as the original was inexplicably deleted)

I noticed this problem on a VM running Xenial in a data centre this week that had been running for 10 years ( upgraded through many Ubuntu LTS releases in that time).

I got tcpdump running to log requests to the URLs in /etc/apt/sources.list and didn't see any requests when I ran apt-get update

e.g.

 tcpdump -i eth0 host archive.ubuntu.com

If I tried to fetch from the host using wget , it worked fine

e.g.

wget archive.ubuntu.com/

Eventually I found that the ISP had set a proxy for apt in /etc/apt/apt.conf on my VM back in 2009 when the VM was first activated.

Acquire
{
  http 
  {
      Proxy "http://apt2.memset.net:3128";
  };
};

Evidently the proxy recently stopped working correctly.

I deleted the block above from my /etc/apt.conf and normality was restored