How to Enable aria2 RPC Server from Terminal?
Enabling the Remote Procedure Call (RPC) server in aria2 allows you to control the lightweight download utility remotely via web interfaces, extensions, or external scripts. By default, this feature is disabled for security and resource management. This article provides a straightforward guide on how to activate the RPC server using specific terminal flags during launch, secure your connection, and verify that the server is running successfully.
The Basic Command to Start the RPC Server
To start aria2 with the RPC server active, you need to append the
--enable-rpc flag when launching the application from your
command line. Open your terminal and run the following command:
aria2c --enable-rpc
When you execute this, aria2 starts a persistent session in your terminal and begins listening for incoming RPC connections. By default, it will listen on IPv4 port 6800 and accept connections from any network interface.
Essential Flags for Security and Configuration
While the basic command works, running an unsecured RPC server exposes your download queue to anyone on your network. It is highly recommended to include additional configuration flags for better control and security.
1. Adding a Secret Token (Recommended)
To prevent unauthorized access, you should set a secure token. Any external interface or application trying to connect to your aria2 instance will be required to provide this token.
aria2c --enable-rpc --rpc-secret=YourSecureTokenHere
2. Allowing All Origins (CORS)
If you are using browser-based web interfaces (like AriaNg or aria2-webui) hosted on a different domain or running locally, you must enable Cross-Origin Resource Sharing (CORS) to allow the interface to communicate with your terminal session.
aria2c --enable-rpc --rpc-allow-origin-all
3. Changing the Default Port
If port 6800 is already in use by another application, or if you
prefer a custom setup, you can change the listening port using the
--rpc-listen-port flag.
aria2c --enable-rpc --rpc-listen-port=8080
Putting It All Together
For a secure, fully functional setup that works seamlessly with web frontends, combine the flags into a single command:
aria2c --enable-rpc --rpc-secret=MySuperSecret123 --rpc-allow-origin-all
Verifying the RPC Server Status
Once you run the command, aria2 will display log outputs directly in your terminal. You can confirm it is working by looking for a line that indicates the IPv4 RPC server has started successfully:
IPv4 RPC: listen on TCP port 6800
If you see this message, your aria2 RPC server is active and ready to accept download commands from your preferred remote interface or automation script.