Articles on: Linux VPS

Speed Up Your apt update: Troubleshooting Slow Performance

If you're experiencing slow performance with the apt update command on a Linux VPS with Ubuntu 20.04, there are several potential causes and corresponding solutions you can investigate:


Slow apt update


Common Causes and Solutions

Note: If you login as user, run this command to login as root : sudo su


  1. Geographically Distant Mirrors


  • Cause: The default repository mirrors may be geographically distant from your location.
  • Solution: Change the mirror to my.archive.ubuntu.com by running :


sed -i -e 's/ru.archive.ubuntu.com/my.archive.ubuntu.com/g' /etc/apt/sources.list

Change apt mirror


Fast apt update


  1. Local Cache Issues


  • Cause: Corrupted or outdated cache can affect apt update.
  • Solution: Clear the local cache by running:
rm -rf /var/lib/apt/lists/*
sudo apt update


  1. DNS Issues


  • Cause: Slow DNS response times can slow down repository access.
  • Solution: Change your DNS settings to use faster public DNS servers, such as Google DNS (8.8.8.8, 8.8.4.4) or Cloudflare DNS (1.1.1.1, 1.0.0.1).
sudo nano /etc/resolv.conf

Update to:

Google

8.8.8.8
nameserver 8.8.4.4


Cloudflare

1.1.1.1
nameserver 1.0.0.1


  • Check current DNS server :


--status``
![Current DNS Server](https://storage.crisp.chat/users/helpdesk/website/67938060e89a4400/windowsterminal-1716803936_qpsb3x.png)

4. **Proxy Server**

* Cause: If you are behind a proxy, the proxy server might be causing delays.
* Solution: Check your proxy settings and ensure they are correctly configured. You can also try bypassing the proxy to see if it improves speed.

5. **Firewall and Network Configuration**

* Cause: Network firewalls or misconfigurations can slow down or block connections.
* Solution: Check firewall rules and network configurations to ensure they're not the bottleneck. Consult with your network administrator if you're in a managed environment.
* Solution: Ubuntu usually preinstalled with _ufw_ firewall.

Check the detailed status of the UFW service:
`sudo ufw status verbose`
![Detailed UFW status](https://storage.crisp.chat/users/helpdesk/website/67938060e89a4400/windowsterminal-1716802970_5s3qww.png)

Stop and disable the UFW service:
`sudo ufw disable`

![ufw disable](https://storage.crisp.chat/users/helpdesk/website/67938060e89a4400/windowsterminal-1716803202_d17mfw.png)
# Additional Tips


* **Run apt update at Different Times of Day**: Sometimes server load varies throughout the day. Running updates during off-peak hours might be faster.
* **Use Parallel Downloads**: Enable parallel downloads in APT for faster updates.
```echo 'APT::Acquire::Retries "3";' | sudo tee -a /etc/apt/apt.conf.d/80-retries
echo 'Acquire::Queue-Mode "access";' | sudo tee -a /etc/apt/apt.conf.d/80-queue-mode



Example /etc/apt/sources.list with Updated Mirrors


Here's an example of how your /etc/apt/sources.list might look after updating to a country-specific mirror:


deb http://my.archive.ubuntu.com/ubuntu/ focal main restricted
deb http://my.archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://my.archive.ubuntu.com/ubuntu/ focal universe
deb http://my.archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://my.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://my.archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://my.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse



By addressing these potential issues, you can often significantly improve the performance of the apt update command.


Updated on: 28/05/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!