Running a Tor relay helps keep the Tor network healthy and improves anonymity for millions of users. If you have an Android device that is often on Wi‑Fi and plugged in, you can contribute without rooting or flashing custom firmware. This tutorial walks you through every step – from installing Termux to configuring Tor, verifying that your relay is reachable, and handling the most common hiccups.
pkg update && pkg upgrade -y
This ensures you have the latest versions of libc, openssl, and other dependencies.pkg install wget curl tar proot -y
Why? wget and curl will fetch the Tor binaries; proot lets us run a Linux‑like environment without root.tor package in its community repository. Enable the x11-repo and root-repo (they contain the package):
pkg install x11-repo root-repo -y
pkg install tor -y
This places the tor executable at ~/../usr/bin/tor.
tor --version
You should see something like Tor version 0.4.7.13. If the command fails, re‑run the install step.
Tor’s default configuration runs as a client. To become a relay we need a custom torrc file.
mkdir -p $HOME/tor/relay
nano) and create torrc:
nano $HOME/tor/relay/torrc
# Basic relay settings
ORPort 9001
Nickname MyAndroidRelay
ContactYourName <your.email@example.com>
# Bandwidth limits – adjust to your plan
RelayBandwidthRate 100 KBytes
RelayBandwidthBurst 200 KBytes
# Directory authority contacts (default list is fine)
# Optional: run as a non‑exit relay (recommended for most users)
ExitPolicy reject *:*
# Data directory
DataDirectory $HOME/tor/relay/data
# Log to file for troubleshooting
Log notice file $HOME/tor/relay/tor.log
Explanation:
Ctrl+O in nano) and exit (Ctrl+X).Tor needs inbound connections on the ORPort you chose (default 9001). The steps differ by router brand, but the general process is:
192.168.1.1 or 192.168.0.1).90019001Running Tor continuously is easier if we launch it as a background process that restarts after reboots.
tor -f $HOME/tor/relay/torrc
You should see log lines ending with Bootstrapped 100%: Done. Leave this terminal open for a few minutes to verify that no errors appear.
Ctrl+C.
cat > $HOME/tor/relay/start_tor.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/bash
# Ensure the data directory exists
mkdir -p $HOME/tor/relay/data
# Start tor in the background, redirecting stdout/stderr to the log file
nohup tor -f $HOME/tor/relay/torrc > $HOME/tor/relay/tor.log 2>&1 &
EOF
chmod +x $HOME/tor/relay/start_tor.sh
$HOME/tor/relay/start_tor.sh
The nohup command detaches Tor from the terminal, allowing you to close the Termux session without stopping the relay.
ps -A | grep tor
You should see a line with tor and its PID.
Termux can execute scripts automatically when the device boots using the termux-wake-lock and termux-boot add‑ons.
termux-boot package from F-Droid (the Play Store version may not include the boot helper):
pkg install termux-boot -y
mkdir -p $HOME/.termux/boot
boot.sh:
cp $HOME/tor/relay/start_tor.sh $HOME/.termux/boot/boot.sh
chmod +x $HOME/.termux/boot/boot.sh
termux-wake-lock
Place this command at the top of boot.sh if you want the lock to be acquired automatically.
cat $HOME/tor/relay/tor.log | tail -n 20
Look for the same Bootstrapped 100% line.
The Tor Project provides a public relay lookup tool. You can check your relay’s status without leaving the phone.
curl https://ifconfig.me
MyAndroidRelay) or for your IP.
Running a relay is a long‑term commitment. You’ll want to keep an eye on bandwidth usage and log size.
tail -f $HOME/tor/relay/tor.log
torrc:
ControlPort 9051
CookieAuthentication 1
Then use telnet localhost 9051 or a GUI client like Nyx (installable via pip install nyx inside Termux).
RelayBandwidthRate and RelayBandwidthBurst values, then restart Tor:
pkill tor
$HOME/tor/relay/start_tor.sh
This usually means another app (or a previous Tor instance) is already bound to port 9001.
netstat -tuln | grep 9001
tor entry, kill it:
pkill tor
ORPort in torrc to an unused port (e.g., 9002) and update the router’s port‑forward rule accordingly.nc -vz YOUR_PUBLIC_IP 9001
It should report open. If it times out, double‑check your router’s port forwarding and any ISP‑level NAT.
Connection refused or Network unreachable. Those indicate routing problems.
torrc. A safe baseline for most home connections is RelayBandwidthRate 50 KBytes and RelayBandwidthBurst 100 KBytes.ORPort line with:
BridgeRelay 1
ORPort 443
and forward port 443.
Termux runs in a sandboxed environment. If you moved the tor directory to external storage (e.g., /sdcard/tor), Android may block write access.
$HOME) as shown.MANAGE_EXTERNAL_STORAGE permission via Android Settings > Apps > Termux > Permissions.termux-services. Install it and create a service file for Tor to get better start/stop handling.openvpn) and route Tor traffic through it. This adds latency but may be the only way to stay online.logrotate -f $HOME/tor/relay/tor.log
(Install logrotate via pkg install logrotate.)
Running a Tor relay is legal in most jurisdictions, but some countries treat Tor traffic suspiciously. Before enabling a relay:
By following the steps above you have turned an ordinary Android phone into a contributing Tor relay, all without rooting or flashing. The device now helps keep the Tor network robust, and you gain a deeper understanding of networking, Linux‑style services, and privacy‑preserving infrastructure.
Remember to monitor bandwidth, keep the software up to date (pkg upgrade -y), and adjust the torrc settings as your network situation evolves. Your contribution, even from a modest home Wi‑Fi connection, makes a measurable difference for users worldwide.









