Email Address:
admin@achik.us achikahmed.info@gmail.com
Our Social Media Profiles:
A local web server on Android allows you to turn your phone into a small testing environment for websites. It helps you host HTML pages, run projects, and view them directly in a browser using localhost. It is useful for learning web development, testing designs, and practicing server basics without needing a computer or root access. Here’s what can be done with a local web server in Termux:
Termux is a terminal emulator application for Android that provides a Linux-like environment. It allows installation of packages, execution of commands, and use of development tools directly on Android without root access.
Below are the simple steps to create and run a local web server on Android using Termux. Follow each command carefully to setup the server, host a basic website, and also make it accessible from the internet using Cloudflared tunnel.
Update Termux packages and prepare the system for installing required tools:
pkg update && pkg upgrade -yInstall Python, which is used to run a simple built-in HTTP web server:
pkg install python -yCreate a project folder and move inside it to store website files:
mkdir mywebsite && cd mywebsiteOpen a text editor to create and write your webpage content:
nano index.htmlCreate a simple HTML page that will be shown in the browser:
<h1>Welcome to My Local Server</h1>
<p>This website is running on Android using Termux.</p>Save the HTML page file:
Press
CTRL + X + Y
Press Enter
Start a local web server on port 8080 and host the website on Android:
python -m http.server 8080Open the hosted website in the browser using this localhost url:
http://127.0.0.1:8080
You can open this url on your browser to access your local server, this url will only loads in your device.
Cloudflared is used to expose your local web server running on Termux to the internet. It creates a public URL so you can access your website from any device or share it with others easily.
Install Cloudflared in Termux:
pkg install cloudflared -yStart your local web server:
python -m http.server 8080Create a public tunnel for the running server:
cloudflared tunnel --url http://127.0.0.1:8080After running the tunnel command, Cloudflared will generate a public URL like https://okay-camcorders-adsl-dynamic.trycloudflare.com which can be opened from any browser. This link allows access to your local server from anywhere in the world using the internet.
You can also edit the index.html file anytime to modify your website content. Any changes you make in the HTML file will be updated instantly on the local server, so you can add text, images, or design changes and see them live without restarting the setup.
You can design your local web server by editing the index.html file. This file controls how your website looks when opened in the browser. You can add modern styles, colors, buttons, images, and a clean layout using HTML and CSS.
Open the file again whenever you want to make changes:
nano index.htmlCreate a more attractive and modern-looking webpage design:
<!DOCTYPE html>
<html>
<head>
<title>My Local Server</title>Add modern styling to make the page look clean and attractive:
<style>
body {
margin: 0;
font-family: Arial;
background: linear-gradient(to right, #141e30, #243b55);
color: white;
text-align: center;
}
.container {
padding: 50px;
}
h1 {
font-size: 40px;
color: #00ffcc;
}
p {
font-size: 18px;
color: #dddddd;
}
button {
padding: 10px 20px;
border: none;
background: #00ffcc;
color: black;
font-size: 16px;
border-radius: 8px;
cursor: pointer;
}
button:hover {
background: white;
}
</style>Add the main content with a simple button and image section:
</head>
<body>
<div class="container">
<h1>Welcome to My Local Server</h1>
<p>Running on Android using Termux</p>
<button onclick="alert('Hello! This is your local server')">Click Me</button>
<br><br>
<img src="http://www.achik.us/wp-content/uploads/2026/05/local-server-sample-image.jpg" alt="Local Server Image" style="border-radius:15px;">
</div>
</body>
</html>After saving the file, refresh the browser and the new modern design will appear instantly on your local server.
Running a local web server on Android using Termux is an easy way to learn web development. You can host and test websites directly from your phone without a computer or root access. With Cloudflared, you can also open your local site from anywhere using a public link.