--- title: Apt-get update issue --- # Fix slow apt-get update issue on Ubuntu/Debian Server While updating or installing new packages in Ubuntu/Debian servers, slow download speeds may occur even when the network connection is running smoothly. If you run the command `# apt-get update`, and experience slow download speeds for packages, it likely means you’re connected to a busy Source Mirror server. Some users report no updates happening, updates stuck at the header, or other issues. Slow speed on Ubuntu/Debian server updates & upgrades can be due to: - Mirror issues - Name server issues - Repository issues - Other unknown issues ## In order to fix `apt-get update`, check the following: - Verify if the correct source repositories are in your `/etc/apt/sources.list` file. - Remove unwanted or unsupported source repositories. - Clean the apt-get cache. - Choose a fast DNS server. ## Method 1: Fixing Name Server Issues 1. **Clear apt-get cache:** ```bash apt-get clean ``` 2. Choose a proper DNS server** Edit resolv.conf file: ```bash vi /etc/resolv.conf ``` **Enter Google/CloudFlare DNS nameservers** The following two are Google DNS, admittedly, if Google is broken, we all think the Internet is broken. Hence the reason of using Google DNS. You can choose other DNS servers like CloudFlare if you want that are fast and reliable. ```bash nameserver 8.8.8.8 nameserver 8.8.4.4 ``` Or CloudFlare Name Server ```bash nameserver 1.1.1.1 nameserver 1.0.0.1 ``` Now save and close the file. 3. Test your changes** Let's put our changes to the test. Do an apt-get update ```bash apt-get update ``` Do and upgrade ```bash apt-get upgrade ``` Finally, do a distribution upgrade ```bash apt-get dist-upgrade ``` Your download speed should be much greater than what you were getting earlier. ## Method 2 **1. Change HTTP to repo in sources.list file** You can check and go with the `official LaunchPad mirror `_ listing or use the country-code method. But we have a much more scientific method. First, you will need to install a tool called **netselect**, which automatically pulls the Ubuntu/Debian source mirror list and benchmark them based on their latency to your Server location. This package is not shipped with Ubuntu/Debian by default, so you have to install it manually: ```bash wget http://ftp.au.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_amd64.deb ``` ```bash dpkg -i netselect_0.3.ds1-28+b1_amd64.deb ``` The following command will call **netselect** to benchmark the top 20 source hosts from the source mirror list: ```bash netselect -s 20 -t 40 $(wget -qO - http://mirrors.ubuntu.com/mirrors.txt) ``` ![](images/aptslow.png) For example, we have established that in our location, repo.extreme-ix.org is going to be fastest mirror server for apt. We are going to use this information to update the mirror list: ```bash vi /etc/apt/sources.list ``` Next, search for the existing server domain (e.g. **us.archive.ubuntu.com**) and then replace it with **repo.extreme-ix.org**. At the prompt, perform this replacement for all entries. Save the sources.list file and run command **# apt update && apt upgrade -y** to update repo source and server packages. ## Method 3 **Transport HTTP mirrors to HTTPS mirrors in sources.list file** **1. Transport source to https.** Transport source from http to https. Open the terminal and run the following command to install apt-transport-https package. ```bash apt install apt-transport-https ``` **2. Edit resources** Just change HTTP to HTTPS and Save the **sources.list** file and run command **# apt update && apt upgrade -y** to update repo source and server packages. ---