Run a Local Web Server on Android

Terminal Guide & Documentation

Run a Local Web Server on Android

This guide explains how to set up a lightweight local web server on your Android device using Termux. This is perfect for testing HTML/CSS/JS projects or practicing web development on the go.

Step 1: Prepare the System

First, update and upgrade your Termux packages to ensure everything is current.

TERMINAL BASH
pkg update && pkg upgrade -y

Step 2: Install Python

Python includes a built-in module for running a simple HTTP server, which is ideal for our needs.

TERMINAL INSTALL
pkg install python -y

Step 3: Create a Project Directory

Create a dedicated folder for your website and navigate into it.

TERMINAL MKDIR
mkdir mywebsite && cd mywebsite

Step 4: Create a Webpage

Use the nano editor to create an index.html file with some basic content.

TERMINAL NANO
nano index.html

Paste the following HTML into the editor:

HTML SOURCE
<h1>Welcome to My Local Server</h1>
<p>This website is running on Android using Termux.</p>

To save in Nano: Press CTRL + X, then Y, then Enter.

Step 5: Start the Web Server

Run the Python HTTP server module on port 8080.

TERMINAL SERVER
python -m http.server 8080

Step 6: Access the Server

Open your mobile browser and navigate to the following local address:

BROWSER URL
http://127.0.0.1:8080

Advanced: Exposing the Server Globally

To make your local server accessible from the internet, you can use Cloudflared.

TERMINAL TUNNEL
pkg install cloudflared -y
cloudflared tunnel --url http://127.0.0.1:8080

Explore More Tools

Nmap

Powerful network discovery and security auditing.

WAFW00F

Identify Web Application Firewalls (WAF).

Cool Commands

Visual and fun terminal commands for Termux.