Turn Your Old Phone Into a Server
pocket servers!!

Imagine this: You've built something amazing and you can't wait to show it to your friend. You're all set to put it on the internet, maybe using an EC2 instance, but there's a hitch โ you can't sign up for those cloud services without a credit or debit card. Stuck in a tough spot, right? No need to worry, though, because I've got your back.
Let's build a server of our own, using one of your old Android phones. ๐ซก
Setting up your Android
F-Droid: take one of those old Android phones of yours, install ๐ F-Droid (open-source app store for Android ) and Hacker keyboard ( will give you a full keyboard with
Ctr,Altetc..)Termux: search ๐ for Termux in F-Droid and install Termux. Termux is a terminal for your phone.
Server in pocket ๐คฉ
open Termux and install root-repo and openssh, nmap.
# Subscribe to additional packages pkg install root-repo # Upgrade pkg upgrade # Install openssh pkg install openssh nmapNote your username, by running
whoamiand set a password# get username whoami # set password passwdNote your IP, you check your phone ( settings> wifi > wifi settings > ip) or use
ifconfig( install if not ), the output may look something like this. just note down the weird number beside inet you can use either of them to ssh into the server. look for rmnet_data0 or wlan0.
start the ssh server using
sshdcommand, don't exit the session, exit the app or turn off your phone, if done the server will stop# Start ssh server sshdNote the ssh server port by running
nmap, it will most probably be 8022
SSH into your Android phone
Turn on your pc and open your favorite Terminal Emulator.
Connect your phone and pc to the same wifi network.
SSH into the server using
ssh -p <PORT> <USERNAME>@<PASSWORD>( replace port, username and password with yours ).# ssh -p <PORT> <USERNAME>@<PASSWORD> # Example in this case it's ssh -p 8022 u0_a117@25.223.72.230Enter your password. You are done, You just ssh into your server ๐
Setting up a node server
install node and neovim ( terminal editor ), for a Linux user it's a home-like experience, you can also install fish, neofetch, wget, curl, git or anything you use for your daily Linux cli activities.
# Install Nodejs pkg install node pkg install neovimset up a node server ( we will use express )
# Create a Folder and go into it mkdir server & cd server # Initialize npm package npm init -y # write to index.js vi index.jspaste the following code don't forget to use
:set pastein neovim for not auto-indentationconst express = require('express'); const app = express(); const cors = require('cors'); app.use(cors()); app.get('/', (req, res) => { res.send('Hello from the server'); }); app.listen('3000', () => { console.log('Server up and running on port 3000'); });install pm2 ( nodejs process manager ) and run the node server
# Install pm2 globally npm i -g pm2 # Run node server pm2 start index.js # pm2 logs - to check logs # pm2 kill - to kill ( not your computer, the node process )wallah!! you are done ๐ฅณ.
Going Live Globally ๐ชฉ
if you go to
http://<YOUR IP>:3000( replace <YOUR IP> with the IP you used to ssh into the server, http://25.223.72.230:300 in this case ). you should be able to see " Hello from the server " on the screen.but there is a problem: you can only access the IP if you are connected to the same wifi network.
Don't worry, there is a way to deal with this, we can use port forwarding services like Ngrok, Localtunnel, Serveo, Teleconsole... the list goes on.
Let's use one of the easiest ways, Serveo. All you have to do is
ssh -R 80:localhost:3000 serveo.net( click here, visit their site for a updated one ).This will give you a link you can share the link with anyone ๐.
