7

sudo apt-get update sometimes becomes stucked:

...
99% [Waiting for headers]

This seems to be a common problem and can have several reasons. For example, on one machine, it was caused because I used a bad proxy server configuration.

Is there a way to systematically analyze the problem? It looked at the man apt-get but could not find any option that provides more information to isolate the problem. Are there any tools besides apt-get that I can use to get more insights?

4 Answers4

12

Better still, just do:

apt-get -o Debug::Acquire::http=true update
Jason
  • 121
  • 1
  • 2
3

I was able to fix it. http://debian.sur5r.net/i3/ (quantal, universe) did not respond. After disabling it, apt-get update succeeds.

Tips for the next one that runs into this problem:

  1. Start synaptic and disable sources until Reload no longer hangs. Especially, 3rd party sources seem to be candidates.
  2. Reactive your sources until you hit the one that causes problems.

synaptic is great for diagnostics. When Reload hangs and you abort it, it prints out the current repository. In my case, it was exactly the bad one:

Failed to fetch http://debian.sur5r.net/i3/dists/quantal/InRelease  
Some index files failed to download. They have been ignored, or old ones used instead.
0

I tried

apt-get -o Debug::Acquire::http=true update

but hat problems to interpret the output.

Then I found this solution based on https://serverfault.com/a/677533:

sudo -s
echo 'Acquire::http::Timeout "1";' >> /etc/apt/apt.conf.d/00timeout
apt update

This will print something like

Ign:7 https://debian.qgis.org/debian jammy InRelease                                                                                                                                                        

after a second, so you can spot the sources which cause the timeout easily and remove or replace them.

By the way:

apt-get -o Acquire::http::Timeout=1 update

seems not working.

Alex
  • 1,062
0

I have this problem on several different versions of Ubuntu ( I am running several VMs at the moment for software testing),and found that restarting my router (which changed my external IP) cured it temporarily. I assume that some sort of rate limiting is the cause