apt-get commands pausing at 'Waiting for headers'

I have a VM running Ubuntu Server 9.10 running a basic web server setup. Whenever I run an apt function it will pause for around 1 minute at 'Waiting for headers...'. It will eventually clear through and continue as normal but it is a bit of an annoyance.

Everything else on the server seems to run fine. Any ideas?


Solution 1:

Some repos have issues with http/1.1 pipelining.

Try adding the following to /etc/apt/apt.conf.d/piplining-off.conf:

Acquire::http::Pipeline-Depth "0";

Solution 2:

Try commenting out your multiverse and universe repos in your /etc/apt/sources.list

Then do a: apt-get clean all

then finally an: apt-get update

See if that clears it up some.

Solution 3:

tldr; Software Source -> Download From -> Other -> Choose Best Server

I had this problem with an ubuntu install. To debug the problem I edited /etc/apt/apt.conf and added Acquire::http::Timeout "3"; which gives a really short timeout and makes it much more obvious what the problem is.

apt-get update then showed a lot of 404's from http://bg.archive.ubuntu.com which was the repository my ubuntu install had chosen.

Under software sources I then went to Download From -> Other -> Choose Best Server. It chose a server in Bulgaria - which actually happened to be the same server, which I suppose bg.archive.ubuntu.com is aliased or redirected to. But in any case, after selecting that server directly rather than the .archive.ubuntu.com alias, apt-get update worked perfectly. This suggests there can sometimes be some kind of problem with DNS or aliasing with the *.archive.ubuntu.com server names, which can simply be resolved by using another server, or even the same server directly by it's non-aliased name.