How to Prioritize Server Locations or Protocols in aria2?

Using Metalink files in aria2 allows you to download files from multiple mirrors and protocols simultaneously, maximizing your download speed. However, you might want to force aria2 to prefer a specific geographic server location or a particular protocol like HTTPS over FTP. By leveraging aria2’s command-line options—specifically --metalink-language, --metalink-location, and --metalink-preferred-protocol—you can control exactly how aria2 weights and selects these connection options.

Filtering by Server Location

Metalink files often include metadata about the geographic location of each mirror, usually represented by two-letter ISO country codes (e.g., us, de, jp). You can instruct aria2 to prioritize mirrors in your preferred region.

aria2c --metalink-location=us,ca example.metalink

In this example, aria2 will give higher priority to connections from the United States and Canada.

Prioritizing Protocols

If a Metalink file lists multiple protocols for the same file, aria2 will look at your preferences to decide which connection to establish first.

aria2c --metalink-preferred-protocol=https example.metalink

This configuration forces aria2 to prioritize secure HTTPS mirrors over standard HTTP or FTP mirrors.

Setting Language Preferences

Similarly to location, if the Metalink file contains different language versions of a file (common in operating system ISOs or media files), you can set your preference.

aria2c --metalink-language=en example.metalink

Combining Preferences for Optimal Routing

To get the absolute best performance and security tailored to your needs, you can combine these options into a single command.

aria2c --metalink-location=de --metalink-preferred-protocol=https example.metalink

This command tells aria2 to actively seek out and prioritize servers that are both located in Germany and utilizing the HTTPS protocol, ensuring a fast, localized, and secure download process.