How to Enable aria2 RPC Interface on Ubuntu
This guide explains how to configure the aria2 download utility on Ubuntu to accept remote commands via its RPC interface. You will learn how to edit the configuration file, set up authentication tokens for security, and start the daemon so you can manage downloads from web interfaces or mobile apps.
Install aria2
Open your terminal and ensure aria2 is installed on your system. Run the following command to install it via the package manager:
sudo apt update
sudo apt install aria2Create the Configuration File
aria2 reads settings from a configuration file. Create the directory and the file using the following commands:
mkdir -p ~/.aria2
touch ~/.aria2/aria2.confOpen the file in a text editor like nano:
nano ~/.aria2/aria2.confConfigure RPC Settings
Add the following lines to the configuration file to enable the RPC
interface. Replace YOUR_SECRET_TOKEN with a strong password
or random string.
enable-rpc=true
rpc-listen-all=true
rpc-listen-port=6800
rpc-secret=YOUR_SECRET_TOKEN
enable-rpc=true: Activates the RPC interface.rpc-listen-all=true: Allows connections from external IP addresses.rpc-listen-port=6800: Sets the default port for RPC communication.rpc-secret: Sets the authentication token required for remote control.
Save the file and exit the editor.
Start aria2 as a Daemon
To keep aria2 running in the background and listening for RPC commands, start it with the conf file specified. Run the following command:
aria2c --conf-path=~/.aria2/aria2.conf -DThe -D flag runs aria2 as a daemon. If you want this to
start automatically on boot, consider creating a systemd service
file.
Verify the Connection
You can test the RPC interface using a web-based frontend like AriaNg
or a command-line tool like curl. Ensure your firewall
allows traffic on port 6800 if you are connecting from a different
machine.
sudo ufw allow 6800/tcpOnce configured, connect your preferred client using the server IP, port 6800, and the secret token you defined.