Turn Your Old Android or iPhone into a Home Server: Step-by-Step Guide 2026

 

An Old Phone Is Actually a Small Computer

That old phone sitting in your drawer hasn't lost its purpose. It has a processor, RAM, storage, and most importantly, it can connect to the internet. Technically speaking, you have a small but fully capable computer in your hands.

Large companies' servers work on the same basic principle: always on, connected to the internet, waiting for requests. The scale is different, of course, but the core idea is the same.

In this guide, we'll turn that old phone into a real server — a messaging server, a file server, a web server. The foundation is the same set of steps for all of them.


Before You Begin

1. Restrict Background App Access

To prevent apps other than your server from consuming resources in the background, you can restrict background access for apps you don't actively use.

Settings → Apps → select app → Battery → Background Activity → Restrict

2. Disable Battery Optimization (For Termux Only)

Settings → Battery → Disable battery optimization for Termux

This prevents the system from freezing Termux in the background. While the screen is locked, the server consumes very little battery. A phone with a 3000 mAh battery can easily last 1 day, and 5000 mAh or more can last 2 days or longer.

3. Turn Off Power Saving Mode

On some phones, power saving mode cuts the Wi-Fi connection. Keep it off for uninterrupted server operation.

Settings → Battery → Power Saving → Off


What Is Termux?

Termux is a terminal emulator that runs on Android. A terminal (command line — a screen where you give commands by typing, not clicking) emulator means it lets you use your phone as if it were a Linux computer.

Normally on Android, everything is managed through apps. Termux breaks through that barrier — you can install packages, start services, and manage files by typing commands directly. In short, Termux turns your phone into a small Linux server.

Where to Download It?

It can be downloaded from three sources, but they are not all equal:

F-Droid → Recommended. The Termux version on F-Droid (a free app store for open-source applications) is always up to date and fully featured.
👉 f-droid.org

GitHub → Same version as F-Droid, available as a direct APK (Android application installation file) download. Suitable for technical users.
👉 github.com/termux/termux-app

Play Store → The Play Store version is also usable and continues to receive updates. However, Termux developers still recommend F-Droid or GitHub because Play Store policies can occasionally restrict certain features.


Setting Up Termux for Your Server

1. Update the Package List

When you first open Termux, the pre-installed packages may be outdated. Start by running:

pkg update && pkg upgrade

When asked for confirmation, type Y and press Enter.

2. Install Essential Tools

pkg install openssh curl wget git nano
  • openssh → For connecting to the phone from another device
  • curl / wget → For downloading files from the internet
  • git → For downloading from code repositories
  • nano → A simple text editor for editing files inside the terminal

3. Grant Storage Permission

termux-setup-storage

The phone will ask for permission — tap Allow.


Router Settings and Port Forwarding

What Is a Public IP?

All devices in your home share a single gateway to the internet, and that gateway's address is your public IP (the address that identifies you on the internet). Just like you need a home address to receive mail, anyone connecting to your server from outside needs this address.

To find your public IP, visit this site in any browser:

whatismyip.com

The number shown is your public IP. Example: 88.243.12.45

What Is a Local IP?

Your router also assigns a local IP (an address valid only within your home network) to each device. To find your phone's local IP, run this in Termux:

ip a

In the output, look for the line under wlan0 that says inet — that number is your phone's local IP. Example: 192.168.1.105

What Is a Static IP and Why Do You Need It?

Every time your router restarts, it may assign a different local IP to your phone. If that happens, your port forwarding rule breaks and the server becomes unreachable from outside. To prevent this, assign a static IP (a fixed address that always stays the same) to your phone.

To do this, access your router's admin panel. Type this in your browser:

192.168.1.1

This is the admin panel address for most routers. The username and password are usually printed on a label on the bottom of your router.

Once inside: DHCP Settings → Static IP / Address Reservation (the name varies by router) → Enter your phone's MAC address (the network identity of your device) and assign a fixed IP. Example: 192.168.1.105

What Is a Port and How Do You Configure It?

A port (a door number — it specifies which service on a device is reached through which door). Think of it like a building: the IP is the building's address, and each floor is a different port. Every service operates from its own floor.

Commonly used ports:

ServicePort
XMPP (messaging)5222
Website (HTTP)80
Website (HTTPS)443
SSH (remote access)22
FTP (file transfer)21

These ports are universally established standards. For example, an XMPP client will try to connect to port 5222 by default because that's the industry standard.

Can You Use a Different Port?

Yes. Instead of 5222, you can open a different port like 9999. The only difference is that you'll need to specify the port manually in the client. In the Conversations app, when entering the server address:

serveraddress:9999

This will establish the connection without any issues. Using a non-standard port is perfectly valid — everyone connecting just needs to know which port to use.

Port Forwarding in the Router Panel

Go to the Port Forwarding / Virtual Server section in your router panel and configure it as follows:

FieldValue
Service nameXMPP
External port5222 (or your chosen port)
Internal port5222 (or your chosen port)
Internal IP192.168.1.105
ProtocolTCP

Save and restart your router.


XMPP Server Setup: Prosody

What Is Prosody?

Prosody is a lightweight and easy-to-install XMPP server. Because it uses few resources, it's well suited for older phones. It runs directly on Termux.

Installation

Type this in Termux:

pkg install prosody

Once the installation is complete, open the configuration file:

nano /data/data/com.termux/files/usr/etc/prosody/prosody.cfg.lua

This file contains all of Prosody's settings. Find this line inside:

VirtualHost "localhost"

Replace it with your own server name. For example:

VirtualHost "home.local"

This name can be freely chosen if there's no external access (only used within the home network). External access will be covered in the next section.

To save: Ctrl + XYEnter

Start Prosody

prosodyctl start

To check if it's running:

prosodyctl status

If you see Prosody is running, your server is up.

Creating Users

Create a separate account for each family member:

prosodyctl adduser ali@home.local

prosodyctl adduser mom@home.local

prosodyctl adduser dad@home.local

After each command, you'll be asked to enter a password. It's normal that nothing appears on screen while typing.


Encryption in Prosody (TLS)

TLS (Transport Layer Security — the protocol that encrypts traffic between the server and the client). Without encryption, messages sent to your server can be intercepted on the network. TLS prevents this.

Home Network Only (Self-Signed Certificate)

Install the required package for encryption in Termux:

pkg install openssl

Create the certificate directory:

mkdir -p /data/data/com.termux/files/usr/etc/prosody/certs

Generate the certificate:

openssl req -x509 -newkey rsa:4096 -keyout /data/data/com.termux/files/usr/etc/prosody/certs/home.local.key -out /data/data/com.termux/files/usr/etc/prosody/certs/home.local.crt -days 365 -nodes

It will ask some questions — you can press Enter for all of them. Then open the prosody.cfg.lua file:

nano /data/data/com.termux/files/usr/etc/prosody/prosody.cfg.lua

Add these lines:

ssl = {
    key = "/data/data/com.termux/files/usr/etc/prosody/certs/home.local.key";
    certificate = "/data/data/com.termux/files/usr/etc/prosody/certs/home.local.crt";
}

Restart Prosody:

prosodyctl restart

Publicly Accessible Server (Let's Encrypt)

Install Certbot (the tool that obtains Let's Encrypt certificates):

pkg install certbot

Obtain the certificate:

certbot certonly --standalone -d home.duckdns.org

Port 80 must be open while this command runs. Once the certificate is obtained, add it to prosody.cfg.lua:

ssl = {
    key = "/etc/letsencrypt/live/home.duckdns.org/privkey.pem";
    certificate = "/etc/letsencrypt/live/home.duckdns.org/fullchain.pem";
}

Let's Encrypt certificates need to be renewed every 90 days. To automate this:

crontab -e

Add this line:

0 0 1 * * certbot renew

This will automatically renew on the 1st of every month. Restart Prosody:

prosodyctl restart

Connecting with Conversations

Everyone installs Conversations (available on F-Droid or Play Store) on their phone. When opening it, select Use my own provider and enter the following details:

FieldValue
Usernameali@home.local
Passwordthe password you set
Server192.168.1.105
Port5222

The Dynamic IP Problem

Your public IP usually stays the same for days or even weeks. It's likely to change only in specific situations: a prolonged power outage, router reset, or an infrastructure change by your internet service provider. It won't change on its own under normal usage.

That said, it's much more practical to have a system that handles IP changes automatically rather than notifying everyone one by one. That's where DDNS comes in.

The Solution: DDNS

DDNS (Dynamic DNS — a service that binds your changing IP address to a fixed domain name) solves this problem. Even if your IP changes, everyone can still reach the server using the same domain name.

Free DDNS services:

  • No-IP → noip.com
  • DuckDNS → duckdns.org

For example, you can register on DuckDNS and get an address like home.duckdns.org. First install the cron service in Termux:

pkg install cronie

crond

Then edit crontab:

crontab -e

Add this line:

*/5 * * * * curl "https://www.duckdns.org/update?domains=home&token=TOKEN&ip="

Replace TOKEN with the code from your DuckDNS account. Now, even if your IP changes, home.duckdns.org will automatically update every 5 minutes.

Accessing the Server from Outside

Family members now use the domain name instead of the public IP when connecting in Conversations:

FieldValue
Usernameali@home.duckdns.org
Passwordthe password you set
Serverhome.duckdns.org
Port5222

As long as the domain name stays fixed, the connection won't break even if the IP changes. If the connection drops, the DDNS update probably hasn't propagated yet — wait a few minutes and try again.


Your Phone Is Now a Server

Once all these steps are complete, your old phone will continue running as an XMPP server in the background even with the screen locked. All that's left is for family members to install Conversations (or any XMPP client) on their phones and log in with the details above. No more WhatsApp — you can now communicate securely over your own server.


Server via Mobile Data and Tunnel

If you don't have a home router or can't set up port forwarding (some ISPs block this), this scenario is for you. You can still run a server over mobile data, but a different method is required.

What's the Problem?

When using mobile data, your carrier doesn't give you a direct public IP. Dozens of users share the same IP, so it's impossible for someone outside to reach your phone directly. Port forwarding isn't an option either because there's no router under your control.

The Solution: Tunnel

A tunnel (a service that creates an encrypted bridge between your device and the outside world) solves this. The tunnel service has a fixed address on the internet. Your phone connects to that address, and all incoming requests are forwarded to you through the bridge. From the outside, it looks just like connecting through a router.

Cloudflare Tunnel Setup

Cloudflare Tunnel is a free and reliable tunnel service.

1. Download cloudflared

pkg install cloudflared

2. Log in to your Cloudflare account

cloudflared tunnel login

This command will give you a link — open it in a browser and log in with your Cloudflare account.

3. Create a tunnel

cloudflared tunnel create home

You can use any name instead of "home". This command will give you a tunnel ID — note it down.

4. Configure the tunnel

nano ~/.cloudflared/config.yml

Write this inside:

tunnel: TUNNEL_ID
credentials-file: /data/data/com.termux/files/home/.cloudflared/TUNNEL_ID.json

ingress:
  - hostname: home.yourdomain.com
    service: tcp://localhost:5222
  - service: http_status:404

Replace TUNNEL_ID with the ID you just received.

5. Start the tunnel

cloudflared tunnel run home

Ngrok Alternative

Ngrok can also be used instead of Cloudflare. It's simpler to set up, but on the free plan the domain name changes every time you restart. For permanent use, Cloudflare is more reliable.

pkg install ngrok

ngrok tcp 5222

Once Ngrok is running, it gives you a fixed address — enter that into Conversations.

Connecting with Conversations

After the tunnel is set up, family members use the tunnel address when connecting in Conversations:

FieldValue
Usernameali@home.yourdomain.com
Passwordthe password you set
Serverhome.yourdomain.com
Port5222

Using It for Other Purposes

In this guide we set up an XMPP server as an example, but the same phone can be used as a server for different purposes. The core steps are always the same — only the software installed and the port opened changes.

If you want to use it as a web server:

pkg install nginx

nginx

Once Nginx (web server software) is installed and running, set up port forwarding in your router as follows:

FieldValue
Service nameWeb
External port80
Internal port80
ProtocolTCP

For HTTPS (encrypted web connection), repeat the same for port 443.

Anyone who types your public IP or DDNS address into a browser will then reach the website on your phone.


iOS: Without Jailbreak

How Is It Different from Android?

On Android, Termux gives us nearly a full Linux environment. On iOS, Apple restricts this freedom. However, iSH (an app available on the App Store that provides a Linux environment on iOS) makes similar things possible.

The key difference is: iSH needs the screen to stay on to keep running in the background. If the screen turns off, the app freezes and the server stops. The solution is to disable auto-lock and keep the phone plugged in.

Settings → Display & Brightness → Auto-Lock → Never

iSH Setup

Download iSH Shell from the App Store. It's free.

When you first open it, a terminal greets you. iSH uses Alpine Linux (a lightweight Linux distribution that uses few resources). The package manager is apk instead of Termux's pkg.

Update the package list:

apk update && apk upgrade

Install essential tools:

apk add openssh curl wget nano

Server via Router

From here, the steps are identical to the Android section: find the phone's local IP, assign a static IP in the router, set up port forwarding, install Prosody, and create users.

To install Prosody:

apk add prosody

To start it:

prosodyctl start

To create a user:

prosodyctl adduser ali@home.local

iOS: Home Network Encryption (Self-Signed Certificate)

apk add openssl

Generate the certificate:

openssl req -x509 -newkey rsa:4096 -keyout /etc/prosody/certs/home.local.key -out /etc/prosody/certs/home.local.crt -days 365 -nodes

Add to prosody.cfg.lua:

ssl = {
    key = "/etc/prosody/certs/home.local.key";
    certificate = "/etc/prosody/certs/home.local.crt";
}

Restart Prosody:

prosodyctl restart

iOS: Publicly Accessible Server (Let's Encrypt)

apk add certbot

certbot certonly --standalone -d home.duckdns.org

Add to prosody.cfg.lua:

ssl = {
    key = "/etc/letsencrypt/live/home.duckdns.org/privkey.pem";
    certificate = "/etc/letsencrypt/live/home.duckdns.org/fullchain.pem";
}

For automatic renewal:

crontab -e

Add this line:

0 0 1 * * certbot renew

Restart Prosody:

prosodyctl restart

Server via Mobile Data and Tunnel

The same logic as the Android section applies. For Cloudflare Tunnel setup:

apk add curl

curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386 -o cloudflared

chmod +x cloudflared

./cloudflared tunnel login

From here, follow the same steps as in the Android section.

Jailbroken iOS

On jailbroken devices, the requirement to keep the screen on is eliminated. Services run truly in the background. In the jailbreak environment, the necessary packages are installed via Sileo or Cydia (app stores for jailbroken devices), and the steps are nearly identical to Android.


Common Mistakes

1. Saving port forwarding without restarting the router
If the router isn't restarted after saving the port forwarding rule, the setting may not activate. Always save and restart.

2. Not assigning a static IP to the phone
When the router restarts, it may assign a different local IP to your phone. This makes the port forwarding rule invalid and the server unreachable from outside. Always assign a static IP to your phone.

3. Not disabling battery optimization
If battery optimization isn't disabled for Termux or iSH, the system may freeze the app in the background. The server appears to be running but connections fail. This is one of the most common issues.

4. Leaving power saving mode on
Power saving mode cuts the Wi-Fi connection. Even if the server is up, it becomes unreachable from outside.

5. Not setting up DDNS auto-update
If DDNS doesn't update automatically when the IP changes, access to the server will be lost. Make sure to set up the crontab for DuckDNS.

6. Not starting Prosody on each boot
When the phone restarts, Prosody doesn't start automatically. You need to run this when opening Termux:

prosodyctl start

To automate this:

nano ~/.bashrc

Add this at the end of the file:

prosodyctl start

Now Prosody will start automatically every time Termux is opened.

7. Entering the wrong port
You opened port 5222 in the router but entered a different port in Conversations, or vice versa. The port in the router and the port in the client must always match.

8. Letting the screen turn off on iOS
iSH freezes when the screen turns off. Users who forget to disable auto-lock can't figure out why the server isn't working. If you're using iOS, the screen must stay on.


Conclusion

As you can see, that forgotten old phone in your drawer can actually become a fully functional server. No expensive hardware or paid services needed — just a few apps, the right settings, and the steps in this guide.

If something goes wrong during setup, go back to the Common Mistakes section — the answer is most likely there. What comes next is entirely up to you. If you started with XMPP, you can add a web server, file server, and other services to the same phone over time. You've grasped the core concept — the rest you can explore on your own.

 If you liked this article, you might also like my other work:

👉 My Medium profile

👉 My Substack profile

👉 My Turkish blog


Comments