Run a server in your Andorid phone

Dinuka Salwathura
2 min readDec 6, 2020
Running htop in Termux in Samsung S7 Edge

Have you ever thought you can use your android phone as a low end server? Most of the phones today are having high amounts of memory and CPU power. I use a Samsung Galaxy S7 edge which is having 4GB or RAM and Octa-core (4x2.3 GHz Mongoose & 4x1.6 GHz Cortex-A53) CPU to run a development server on it.

I’m a fan of running servers in arm based small computers like raspberry pi. So running a server in android is also fun. Let me show how to work it out.

First you need to install Termux, which is an android application in play store.

A new Termux session

Termux is an Android terminal emulator and Linux environment app that works directly with no rooting or setup required. A minimal base system is installed automatically — additional packages are available using the APT package manager. — termux.com

After installing termux you can work in your android phone like in a linux computer. There are lot of commonly used linux binaries compiled for arm and they have made them available via an apt wrapper ‘pkg’ in termux. So like in ubuntu you can hit ‘pkg install nodejs-lts’ and install nodejs in your andorid phone. For a database mariadb is avilable to install via pkg. Many programming languages can be installed also like python, nodejs, perl, c with gcc.

To remotely connect to your termux you can install openssh via ‘pkg install openssh’. Then you can ssh into termux like you ssh into a virtual private server(vps) like you ssh into aws ec2.

There are some limitations in this approach like if you run termux without rooting, some programs wont be able to run like docker. Becuase there will be issues when creating virtual networks and people have made programs which can emulate sudo environment. So all these hacks are being used if you take a non root approach.

And the best part is you can use this method to run a server which is accessible from internet, exposing your termux host to internet using tunnel applications like ngrok and localhost.run.

Enjoy hacking with Termux!

Here are some guides to install applications to termux,

--

--

Dinuka Salwathura

Computer Science Engineer | Co-Founder of Stack Technologies(Exited in 2022)), Hybriteq & Tripmo | https://dinukasal.github.io