Apt update takes 6/7 minutes, should take seconds

When I run 'lsof -i' in another terminal it has 3 connections to canonical, this seems excessive.

Upgrades seem to run OK but the whole process takes longer than is 'normal'.

It's 18.04 upgraded from 16.04 with virtualbox os's on but not running when updates are done I have other 18.04's without this problem, upgraded in the same way.

Any ideas?

Can you try a different mirror on the machine that you are having issues with? Does that make any difference?

I have seen complaints of slowness when there is an IPv4 and IPv6 network configuration issues. Lets try this command and see if there is any difference in speed:

sudo apt-get -o Acquire::ForceIPv4=true update

1 Like

I, in the Northeast, do very well with rtfm.mit.edu. Having the Repositories button search for the fastest ping will very likely get you the fastest server.

I tried the above command and it cut update time in half, how do you make this permanent? Also I don't think my router (standard uk post office) does ipv6 and there is no issue on the other 18.04 versions.
It still takes more than 3 minuets and I'm not sure why.
Thanks for help.

I can't seem to find the "Repositories button", is there a way to do this on the cmdline?
Thanks for reply.

To change your repos via the command line you simply need to edit /etc/apt/sources.list and change the respective repos to the one you wish to use. I would recommend making a backup of the file before making any changes.

To make the change via the GUI simply run Software & Updates from the Menu and in the section where is says Download from change to a different mirror.

After you make the change to a different mirror. Let's have you do a normal apt update and see what the speeds are like and then have you do one with the command I gave you in the previous post and see where we are speed wise.

Thanks, sussed the GUI controls. Changed to a url near me and did the fastest ping test thingy, all to no avail, I'm afraid update time is up to 10 minuets now! Went back to "standard" uk server 'gb.archive.ubuntu.com/ubuntu', still 10 minuets.
Fastest time so far is with ipv6 disabled as franksmcb suggested but still not sure why it takes even 3/4 minuets on this setup.
Thanks again.

If you want to make the force IPv4 persistent when using apt you can do so by:



Then adding this to the file:

Acquire::ForceIPv4 "true";

You could do it all with just this command as well:

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

Good luck and hopefully that helps to alleviate that issue on the particular system.

Thanks, I will try this. Will it also work with 'unattended updates' which I would also like to disable but that is perhaps another topic.
Will let you know how it goes.

It should work with "unattended updates" as is uses apt.

If you want to enable/disable them this is a pretty good run-down:


Thanks this has more or less solved the problem. Set a persistant option to force ipv4 only and unset the unattendend-updates and learnt a bit in the process. Still not sure why this happened, especially as
nearly identical setups don't have this problem.
Thanks agian.