How To Fix Slow Pacman Downloads On Arch Linux

How To Fix Slow Pacman Downloads On Arch Linux

How to Fix Pacman & Yay Slow Downloads on Arch Linux

Struggling with sluggish updates or "could not resolve host" errors on Arch Linux? These bottlenecks are typically caused by inefficient DNS resolvers or outdated package mirrors that are physically distant from your location.

Welcome back to MusaBase! Whether you have just finished a minimal Arch Linux installation or you are currently customizing your KDE Plasma desktop, slow download speeds can make the process frustrating. In today's guide, I will show you how to fix slow download issues in both Pacman and yay, while also configuring /etc/resolv.conf for a faster, more reliable connection.

In this guide, we will cover:

  • Adding Google and Cloudflare Public DNS for hostname resolution
  • Installing and configuring Reflector, a powerful mirror optimization tool
  • Updating your mirrorlist with the fastest and most secure servers
  • Optimizing Parallel Downloads to fetch multiple packages at once

By the end of this tutorial, you will have resolved your Pacman and yay speed issues and established a solid DNS configuration. Let’s get started!




The Problem: Pacman & yay Errors

Before we dive into the fixes, let's identify the symptoms. If you are seeing any of the following errors in your terminal, your DNS or mirrorlist is likely misconfigured or outdated.

If these look familiar, the following steps will resolve them.







Adding DNS Nameservers

When we run a command like sudo pacman -S firefox, your system needs to find the exact location of the mirror server (e.g.mirror.rackspace.com). Since computers communicate through IP addresses, a DNS acts as an interpreter.

By default Arch Linux uses the DNS provided by your ISP, if it is slow, outdated, or unreliable, your system fails to find the server's IP, resulting in the most common error known as: could not resolve host. In this step we will add publicly accessible nameservers provided by Cloudflare and Google, which will ensure that our system always finds the fastest path to the Arch mirrors.

We can solve this problem using two different methods:

  • Temporary Solution: By manually configuring /etc/resolv.conf
  • Permanent Solution (Specific & Global): By using NetworkManager's command-line tool nmcli

For a fast and immediate fix, you can follow Step 1.1. However, please note that these settings will revert to defaults after a network restart or a system reboot. For a long-term fix, follow Step 1.2 to make your DNS configuration persistent.


Step 1.1: Adding Nameservers Temporarily

  • To add nameservers, we first need to open the /etc/resolv.conf file.
  • Run the following command:
sudo nano /etc/resolv.conf
  • In the /etc/resolv.conf file, remove the existing nameserver if already exist.
    • Usually it looks like: 192.168.xx.xx
  • Add the following nameservers:
nameserver 1.1.1.1
nameserver 8.8.8.8
  • After adding the nameservers, press CTRL + O to save the files, then press ENTER to apply the changes, and press CTRL + X to exit the file.

1.2: Adding Permanent Nameservers for a Specific Connection

Using this method, you will set custom DNS for only one specific connection at a time, such as your Home Wi-Fi, Ethernet, or Mobile Hotspot. If you want to set these DNS settings globally for every network you connect to, please skip to Step 1.3. Otherwise, follow the steps below for your current network:

To add nameservers permanently we need the NMCLI tool to tell the Arch Linux system to disable the auto configured DNS resolving and use our added nameservers instead. To make the custom nameserver changes permanent, follow these steps:

  • Open terminal and run:
nmcli connection show
  • This will print out your list of connection-profiles.
  • Since, I'm connected to internet via my ethernet cable, it is showing my connection name as Wired connection 1.
  • If you are connected through Wi-Fi or hotspot, it may show you Wifi connection 1 or your wifi name.
  • Note the name of your currently connected connection.
  • Run the following command by adding your connection name in it.
sudo nmcli con mod "Wired connection 1" ipv4.ignore-auto-dns yes
  • Next, run nmcli command again with nameserver addresses:
sudo nmcli con mod "Wired connection 1" ipv4.dns "1.1.1.1 8.8.8.8"
  • After the changes, we also need to restart the connection with this command:
sudo nmcli con up "Wired connection 1"

1.3: Adding Permanent Nameservers Globally

If you want a "set and forget" solution, this method is for you. Unlike the previous step, this configuration enforces your custom DNS settings globally across the entire system.

This method ensures that your custom DNS settings remain active across all networks. Whether you are connecting to your university Wi-Fi, a friend's hotspot, or any public network, Arch Linux will strictly use your defined nameservers for every connection.

  • To set nameservers globally, first we need to create a global-dns.conf file.
  • Open terminal and run:
sudo nano /etc/NetworkManager/conf.d/global-dns.conf
  • The file will be empty.
  • Next, in the file add the following lines:
[main]
dns=default

[connection]
# Block all Auto DNS Provided by ISPs
ipv4.ignore-auto-dns=yes

[global-dns-domain-*]
servers=1.1.1.1,8.8.8.8
  • After adding the lines, press Ctrl + O to save the changes, then press Enter to apply the changes, then press Ctrl + X to exit the file.
  • Next for networkmanager to apply and use the custom added nameserver, we need to restart it.
  • Run:
sudo systemctl restart NetworkManager

# OR

sudo nmcli connection up "Wired connection 1"
  • Now to verify that your custom added nameservers, run:
cat /etc/resolv.conf
  • If you still see your ISP provided DNS even after disabling it in the global-dns.conf file, run the following command to shut it down indefinitely:
sudo nmcli connection modify "Wired connection 1" ipv4.dns ""
sudo nmcli connection up "Wired connection 1"

Revert DNS Configurations back to Defaults

If you are facing issues after configuring your DNS settings with permanent process, or want to use the ISP provided DNS, you can always revert back to defaults.


Revert DNS Settings back for Specific Connection

  • To revert back the DNS settings back to defaults for specific connection, run consecutively:
sudo nmcli connection modify "Wired connection 1" ipv4.dns ""
sudo nmcli con mod "Wired connection 1" ipv4.ignore-auto-dns no
sudo nmcli connection up "Wired connection 1"

Revert DNS Settings back Globally

  • If you followed and created the global-dns.conf file, then do the following:
sudo mv /etc/NetworkManager/conf.d/global-dns.conf /etc/NetworkManager/conf.d/global-dns.conf.bak

# OR
sudo rm /etc/NetworkManager/conf.d/global-dns.conf



Install Reflector & Update Mirrorlist

A Mirrorlist is a configuration file used by the package manager to identify the servers from which packages and updates are downloaded. Since high global traffic can make a single central server slow or even unresponsive, Linux distributions use mirrors. These are multiple servers around the world that host identical copies of the distribution's software repositories, acting just like a CDN to ensure fast and reliable downloads.

To set or update mirrorlist we can use reflector. It is a Python script which can retrieve the latest mirror list update the existing local mirrorlist file with fastest mirrors.

Install Reflector

  • To install reflector, simply run:
sudo pacman -Syu
sudo pacman -S reflector

Create Backup of Existing Mirrorlist

  • First, create the backup of existing mirrorlist with:
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak

Update Mirrorlist

  • Now, run:
sudo reflector --verbose --country 'Singapore,India,Germany' --latest 20 --protocol https --sort rate --connection-timeout 15 --save /etc/pacman.d/mirrorlist
  • Next, we need to sync the database with new mirrors.
  • Run:
sudo pacman -Syyu



Step 3: Optimize Parallel Downloads

By default, Pacman downloads packages five at a time or one by one. Even with the fastest mirrors, this can feel slow if you are installing a large desktop environment like KDE Plasma or GNOME. To fix this, we need to configure the pacman.conf file for Parallel Downloads.

  • Open the Pacman configuration file:
sudo nano /etc/pacman.conf
  • Look for the line ParallelDownloads = 5 or #ParallelDownloads=5.
  • Remove the # if present to enable this feature. You can also increase the number (e.g., 10) if you have a high-speed connection.

ParallelDownloads = 10
  • To save the changes, press Ctrl + O, then press Enter, and to exit the file, press Ctrl + X.


What’s Next?

With your DNS configured and mirrorlist optimized, your Arch Linux system is now primed for high-speed performance. No more "could not resolve host" errors or frustratingly slow updates. Now that your package manager is firing on all cylinders, it's time to build your perfect setup.

Level Up Your Arch Journey

πŸ–₯️ Desktop Environments: Choose your perfect interface. Install a sleek and user-friendly KDE Plasma desktop for a polished daily driver experience.

Next-Gen Customization: Dive into modern tiling window managers. Transform your workflow with a visually stunning Hyprland setup using pre-configured dotfiles.

Virtualization Power: Run other operating systems seamlessly. Learn to create near-native performance VMs with QEMU/KVM for development or testing.

πŸ› ️ Foundation First: If you're starting from scratch, ensure a solid base with my complete Arch Linux installation guide.

This concludes the guide on fixing slow Pacman and Yay downloads. If you’re still experiencing speed bottlenecks or need help with Reflector configurations, feel free to drop a comment below. I’m always here to help you optimize your Arch system!

101 out, I’ll see you in the next one!

Load comments