Free Port Forwarding with Termux

July 15, 2023 8 min read By Sandeep Bhondwe

Port Forwarding in Action

Watch this demonstration of free port forwarding using Termux, brought to you by Sandeep Tech. The video shows the complete process from installation to running the port forwarding service. This visual guide will help you understand how to expose your local services to the internet without any cost.

Port forwarding is a powerful networking technique that allows you to expose local services to the internet. With Termux and the free `localhost.run` service, you can set up port forwarding on your Android device without any complex configurations or paid services. This guide from Sandeep Tech will walk you through the entire process step by step.

100%
Free Service
No Root
Required
Secure
SSH Tunnel
Easy
To Setup

What is Port Forwarding?

Port forwarding allows external devices to access services on a private network. Normally, devices on your local network (like your phone on Wi-Fi) are hidden from the internet by your router. Port forwarding creates a secure tunnel that directs specific internet traffic to a device on your private network, making a local service publicly accessible.

localhost.run for Security

This method uses localhost.run, which creates a secure SSH tunnel between your Android device and its public servers. As explained by Sandeep Bhondwe, this means you can expose local services without opening ports on your router or revealing your public IP, making it a much safer alternative to traditional port forwarding.

Why Use Port Forwarding on Android?

There are many practical reasons why you might want to set up port forwarding from your phone:

  • Host a Website - Host a personal website or blog directly from your Android device.
  • Remote Access - Access files or services on your device from anywhere.
  • Development & Testing - Show a client a website you are developing without deploying it.
  • Game Servers - Host lightweight game servers that friends can connect to.
  • IoT Projects - Expose services from IoT devices connected to your phone.

Installation Guide for Termux

Setting up the port forwarding tool in Termux is straightforward. First, ensure your Termux packages are up to date:

# Update and upgrade Termux packages
apt update -y && apt upgrade -y

Next, install `wget`, which is required to download the setup script:

# Install wget package
apt install wget -y

Now, download and run the setup script from Sandeep Tech:

# Download and run the setup script
wget https://link.sandeeptech.com/localhost-setup && bash localhost-setup

The installation script will automatically download and configure all necessary components. Once complete, you can start the tool with this command:

# Start the port forwarding tool
localhost

Running the Tool

The port forwarding tool from Sandeep Tech makes using `localhost.run` incredibly simple. Here’s what you'll see when you run the script:

termux@localhost:~$
termux@localhost:~$ localhost
�� Welcome to Sandeep Techs Server ======================================================== My script forwards your local port using sandeeptech Enter the port number (1-65535): 4444 🌐 Setting up port forwarding for port: 4444 🔗 Generating your public URL... The authenticity of host 'localhost.run (54.82.85.249)' can't be established. RSA key fingerprint is: SHA256:FV8IMJ4IYjYUTnd6on7PqbRjaZf4c1EhhEBgeUdE94I This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 🎉 Your public URL: https://235317c1716882.lhr.life ========================================= Keep this script running to maintain the tunnel. Press [CTRL+C] to stop the forwarding. ========================================= ^C Stopping port forwarding... Redirecting to https://sandeeptech.com ...

Using the Port Forwarding Tool

The tool provides a simple command-line interface. To start a tunnel:

  1. Run the command `localhost`.
  2. When prompted, enter the local port of the service you want to expose (e.g., `8080` for a web server).
  3. If it's your first time connecting, you may be asked to verify the host authenticity. Type `yes` and press Enter.
  4. The tool will provide you with a public HTTPS URL.

Once the tunnel is active, you can access your local service from anywhere using the provided URL. The connection is automatically secured with HTTPS.

Advanced Options

The script simplifies the process, but you can also use `localhost.run` with more advanced configurations:

Multiple Tunnels

You can run multiple tunnels simultaneously by opening new Termux sessions and running the `localhost` command again for different local ports.

Manual Connection

You can also connect to `localhost.run` manually using the `ssh` command for more control. For example, to forward a different remote port, you can use:

# Manually forward local port 8080 to a random public URL
ssh -R 80:localhost:8080 localhost.run

Troubleshooting

If you encounter issues, here are some common solutions:

Common Issues

  • Tunnel Not Starting: Check your internet connection. `localhost.run` requires a stable connection to maintain the SSH tunnel.
  • Connection Refused: Verify that your local service (e.g., a web server) is running correctly on the specified port *before* starting the tunnel.
  • Connection Timed Out: Free `localhost.run` tunnels may time out after a period of inactivity. Simply restart the script to get a new URL.

Security Considerations

While using an SSH tunnel is secure, it's vital to protect the service you are exposing:

  • Least Privilege: Only expose services that absolutely need to be publicly accessible.
  • Authentication: Implement strong authentication on your application or service.
  • Keep Software Updated: Regularly update Termux, your applications, and any servers you are running to patch security vulnerabilities.
  • Monitoring: If possible, monitor access logs for suspicious activity.

Interactive Demo

Try Port Forwarding Commands

Experience the power of port forwarding with our interactive command simulator. Try running some basic commands to see how they work.

termux@localhost:~$
termux@localhost:~$ Type a command or click a button below

Command Reference

Port Forwarding Commands

Command Description Example
localhost Start the port forwarding tool localhost
apt update -y && apt upgrade -y Update Termux packages apt update -y && apt upgrade -y
ssh -R 80:localhost:8080 localhost.run Manually start a quick tunnel ssh -R 80:localhost:3000 localhost.run
ps aux | grep ssh Check if an SSH tunnel is running ps aux | grep ssh
pkill ssh Stop all SSH processes pkill ssh

Port forwarding with Termux and `localhost.run` is a powerful and free solution for exposing local services to the internet. Whether you're a developer testing applications, hosting a personal website, or setting up remote access, this tool from Sandeep Tech provides a simple and secure way to achieve your goals without any cost.

Back to Blogs

Leave a Comment

Alex Johnson
July 16, 2023
Amazing tutorial! I've been looking for a free port forwarding solution for my Android device. This worked perfectly and I was able to host my personal blog in minutes. Thank you for sharing this!
Maria Garcia
July 17, 2023
This is exactly what I needed! I'm a developer and often need to test web applications on different devices. This tool makes it so easy to expose my local development server to the internet for testing. Great job!