Commands.page Logo

How to Configure aria2 DNS Timeout on Ubuntu Linux

This guide explains how to adjust the DNS resolution timeout settings for aria2 on Ubuntu. You will learn where to locate the configuration file, which specific parameter controls DNS timing, and how to apply these changes to improve download stability when facing network latency issues.

Install aria2

If you have not installed aria2 yet, open your terminal and run the following command to install it from the official repositories:

sudo apt update
sudo apt install aria2

Locate the Configuration File

aria2 looks for a configuration file in ~/.aria2/aria2.conf. If this file does not exist, you need to create the directory and the file. Run the following commands to set up the directory structure:

mkdir -p ~/.aria2
touch ~/.aria2/aria2.conf

Set the DNS Timeout

Open the configuration file using a text editor like nano:

nano ~/.aria2/aria2.conf

Search for the dns-timeout parameter. If it is not present, add it to the file. This value is set in seconds. For example, to set the timeout to 30 seconds, add the following line:

dns-timeout=30

You can adjust the number based on your network conditions. A higher value prevents premature failures on slow networks, while a lower value fails faster on unreachable hosts.

Apply the Changes

Save the file and exit the editor. If aria2 is running as a daemon or background service, you must restart it for the changes to take effect. If you are running commands manually, the new settings will apply to the next command execution automatically.

To verify the setting is active, you can run aria2 with the verbose flag to see loaded configurations:

aria2c --show-console-readout=true -V

Your DNS resolution timeout is now configured to handle network delays more effectively.