Vhtforums
AI Assistant
Ubuntu apt update V...
 
Notifications
Clear all

Ubuntu apt update VERY slow and how to fix your download speed

1 Posts
1 Users
0 Reactions
8 Views
Brandon Lee
Posts: 701
Admin
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@brandon-lee)
Member
Joined: 16 years ago
[#546]

I recently ran into an issue with a cloned Ubuntu 24.04 template that was using as a Bitbucket runner, so it didn't need anything too special. However, after spinning it up, I noticed trying to install packages was brutally slow. Was getting like 20-35 kb/sec downloads. Here are ultimately the tweaks and steps I took to get the apt update working fast once again:

Step 1: Force APT to use IPv4

If you are not using IPv6 in your environment, this keeps APT from wasting time trying broken or unreachable IPv6 paths.

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

You can make sure it "sticks" with the following:

cat /etc/apt/apt.conf.d/99force-ipv4
 

You should see something like this:

Acquire::ForceIPv4 "true";
 

Step 2: Change Ubuntu repositories from HTTP to HTTPS

This is the one that I found made the biggest difference, since it looks like it is hitting cloudflare IPs. On Ubuntu 24.04 (Noble), edit the .sources file with this:

sudo sed -i \
's| http://archive.ubuntu.com/ubuntu|https://archive.ubuntu.com/ubuntu|g; 
 s| http://security.ubuntu.com/ubuntu|https://security.ubuntu.com/ubuntu| g' \
/etc/apt/sources.list.d/ubuntu.sources
 

Make sure of your changes.

cat /etc/apt/sources.list.d/ubuntu.sources
 

You should now see:

URIs:  https://archive.ubuntu.com/ubuntu 
 

and this also:

URIs:  https://security.ubuntu.com/ubuntu 
 

Step 3: Refresh APT

Now refresh APT:
sudo apt clean
sudo apt update
 

Step 4: Test download speed

To make sure of your speed improvement, below is just an example that I used since I was trying to install JAVA:

wget -4 -O /dev/null \
 https://archive.ubuntu.com/ubuntu/pool/main/o/openjdk-17/openjdk-17-jre-headless_17.0.19 +10-1~24.04.2_amd64.deb
 
After this, I was getting this:

 

45.86 MB in 3.2 seconds
≈14.5 MB/sec

Leave a reply

Author Name

Author Email

Title *

The advanced attachments is disabled for guests
 
Preview 0 Revisions Saved