Run a Homelab Server on an Old Android Phone with Termux
🤖 Researched and drafted automatically from the official docs, and reviewed before publishing. Commands are taken from the source projects — but always sanity-check before running anything on your own hardware.
You’ve got an old phone in a drawer. It has a CPU, RAM, and storage. Termux turns it into a real Linux environment where you can run actual services—databases, web servers, automation scripts—without paying cloud providers. It’s not a replacement for serious compute, but for light workloads and always-on tasks, a phone beats nothing and beats paying AWS or DigitalOcean month after month.
Termux is an Android terminal and Linux environment. It gives you a shell, a package manager, and access to the underlying Linux kernel. You can install standard tools: Python, Node.js, PostgreSQL, nginx, cron, git, SSH. The catch: Android 12+ aggressively kills processes, and battery drain is real if you don’t manage it. But for a phone plugged in on your shelf, running a small database or webhook listener, it works.
Install Termux
-
Download Termux from F-Droid (recommended for stability) or GitHub Releases. F-Droid is slower to update but more stable; GitHub has latest builds.
- F-Droid: https://f-droid.org/en/packages/com.termux/
- GitHub Releases: https://github.com/termux/termux-app/releases (download the APK matching your Android version and CPU architecture)
-
Install the APK on your phone. If you already have Termux from another source, uninstall it first—don’t mix sources, or signature mismatches will block installation.
-
Open Termux. You’ll see a black terminal. You’re now in a Linux shell.
-
Update the package list:
apt update
- Upgrade existing packages:
apt upgrade
Answer y when prompted. This can take a few minutes.
Disable Android Process Killing (Android 12+)
Android 12 and later kill processes aggressively. If you’re running Android 12+, you need to tell the system not to trim phantom processes or kill apps for high CPU use.
-
Open Settings on your phone.
-
Navigate to Developer Options. (If not visible: go to About phone, tap Build Number seven times.)
-
Scroll to Phantom process killer or Process termination settings.
-
Disable phantom process killing and high CPU process killing for Termux.
Without this, long-running services will die silently with [Process completed (signal 9) - press Enter] and no error.
Install Core Packages
Install a baseline set of tools for running services:
apt install openssh curl wget git python pip nodejs htop
This gives you SSH (to connect remotely), web tools, version control, scripting languages, and system monitoring. Each apt install takes 30 seconds to a few minutes depending on package size and your phone’s storage speed.
Set Up SSH for Remote Access
SSH lets you connect to your phone from your laptop without touching the screen.
- Start the SSH server:
sshd
- Check which port it’s listening on (usually 8022 by default in Termux):
ss -tlnp | grep ssh
You’ll see something like LISTEN ... :8022. Note that port.
- Find your phone’s local IP address:
ifconfig
Look for inet under wlan0 (Wi-Fi). It’ll look like 192.168.x.x.
- From your laptop, connect:
ssh -p 8022 u0_a<numbers>@192.168.x.x
The username is your Termux user ID (printed when you first run apt). You’ll be prompted for a password; Termux doesn’t enforce one by default, so just press Enter or set one with passwd.
Run a Simple Service: Python HTTP Server
Test that services stay alive. Create a simple Python script:
cat > /data/data/com.termux/files/home/server.py << 'EOF'
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Server running on port {PORT}")
httpd.serve_forever()
EOF
Run it:
python /data/data/com.termux/files/home/server.py
From another device on your LAN, visit http://192.168.x.x:8000. You’ll see your phone’s filesystem. It works.
To keep this running after you close Termux, use a terminal multiplexer like tmux or screen, or write a startup script in Termux:Boot (a plugin).
Install Termux:Boot (Optional but Useful)
Termux:Boot runs scripts when your phone boots, keeping services alive across reboots.
-
Install the Termux:Boot plugin APK from the same source as Termux (F-Droid or GitHub).
-
Create a boot script directory:
mkdir -p ~/.termux/boot
- Create a startup script (e.g., to start SSH and a service):
cat > ~/.termux/boot/start-services << 'EOF'
#!/data/data/com.termux/files/usr/bin/bash
sshd
python /data/data/com.termux/files/home/server.py &
EOF
- Make it executable:
chmod +x ~/.termux/boot/start-services
- Grant Termux:Boot permission to run on boot (via Android Settings > Apps > Permissions).
Now your services restart automatically when the phone boots.
Keep It on Your LAN, Never Expose to the Internet
Critical: Do not port-forward your phone’s SSH or services to the public internet. A phone is not a hardened server. It has no firewall, limited security updates, and runs a mobile OS. Keep it behind your router, on your home Wi-Fi only. If you need remote access, use a VPN (WireGuard, Tailscale) to your home network, then connect to the phone from there.
Monitor Battery and Heat
Running services drains the battery and generates heat. Keep the phone plugged into power. Monitor CPU and memory:
htop
Press q to quit. If a process is using >50% CPU constantly, it’ll overheat the phone and damage the battery. Termux on Android 12+ will kill it anyway, so keep workloads light.
Realistic Workloads
What works well on a phone:
- A small database (SQLite, lightweight PostgreSQL instance)
- A webhook listener (Node.js or Python Flask app)
- Cron jobs that run scripts on a schedule
- A file server (nginx or Samba)
- A personal VPN server (WireGuard)
- Log aggregation or monitoring agents
What doesn’t:
- Heavy machine learning or video encoding
- Serving hundreds of concurrent requests
- Running a Kubernetes cluster (though you could run a single-node deployment for learning)
Is It Worth It?
Yes, if you have a spare phone and want to learn Linux, experiment with services, or run a low-traffic personal tool. You save money on cloud bills and gain a tactile understanding of how services actually run. No, if you expect it to be reliable or fast—phones are fragile, storage is slow, and Android can kill your processes without warning. Use it as a learning tool or a hobby project, not a production system. And keep it on your LAN.
Sources
Related video
New self-hosted AI & homelab shorts, daily.
Subscribe on YouTubeRelated guides
Turn an old webcam into an AI security camera with Frigate
Run Frigate NVR on a spare PC to detect people, cars, and animals in real-time from cheap IP cameras or old USB webcams. Local processing, no cloud, integrates with Home Assistant.
Turn a $15 Android TV Box into an Armbian Linux Server
Flash Armbian on Amlogic S905/S922 TV boxes to run Docker, Pi-hole, and other services. Boot from USB first—eMMC flashing can brick it.
Turn an Old Laptop into a Home Server with CasaOS
Install CasaOS on Debian/Ubuntu with one command and get a click-install app store for Jellyfin, Nextcloud, Home Assistant. Runs on x86 and ARM.