How Does aria2 Resume Interrupted Downloads?

This article explains the underlying mechanism aria2 uses to resume interrupted HTTP and FTP downloads. It covers how the utility tracks download progress through control files, leverages protocol-specific headers like Range and REST, and ensures file integrity during a session restart.


The Core Mechanism: The Control File (.aria2)

The secret to aria2’s ability to pick up exactly where it left off lies in its control file. When you start a download, aria2 creates a companion file with the .aria2 extension alongside your target file.

When a download is interrupted by a network drop or user cancellation, the .aria2 file remains on your disk. When you re-run the command, aria2 reads this file to reconstruct the download state, preventing the need to start from scratch.


Protocol-Level Resuming

Once aria2 knows which parts of the file are missing, it uses standard network protocol features to request only the remaining data from the server.

HTTP/HTTPS Resuming

For HTTP downloads, aria2 utilizes the standard Byte Ranges specification (RFC 7233).

  1. Server Capability Check: aria2 checks if the server responded with the Accept-Ranges: bytes header during the initial connection.
  2. The Range Header: If supported, aria2 sends a request with a Range header specifying the exact byte offsets it needs. For example, Range: bytes=5000-10000 tells the server to skip the first 5,000 bytes and only transmit the requested chunk.

FTP Resuming

For FTP downloads, aria2 relies on the REST (Restart) command.

  1. Setting the Offset: Before initiating the file transfer via the RETR (Retrieve) command, aria2 sends REST <byte-offset> to the FTP server.
  2. Data Stream: The server moves its file pointer to that specific position and streams the data from that point forward.

File Integrity and Validation

Resuming a download introduces the risk of data corruption if the remote file changed while the download was paused. To protect against this, aria2 employs validation checks.