Logo

dev-resources.site

for different kinds of informations.

Accessing a Laptop's Server on Port 80 from Your Phone via Wireless Debugging

Published at
1/12/2025
Categories
adb
wireless
localhost
developer
Author
Ashen Chathuranga
Categories
4 categories in total
adb
open
wireless
open
localhost
open
developer
open
Accessing a Laptop's Server on Port 80 from Your Phone via Wireless Debugging

This guide explains how to access a server running on port 80 on your laptop from your phone using wireless debugging and Chrome DevTools.

Prerequisites

  1. ADB (Android Debug Bridge) installed on your laptop.
  2. Both your laptop and phone must be on the same Wi-Fi network.
  3. A server running on your laptop's port 80 (e.g., a local web server).

Step 1: Enable Wireless Debugging on Your Phone

  1. Enable Developer Options on your Android phone:

    • Go to Settings > About Phone.
    • Tap Build Number 7 times to unlock Developer Options.
  2. Navigate to Developer Options and enable Wireless Debugging.

  3. Pair your phone with your laptop:

    • Get your phone's IP address:
      • Go to Settings > Wi-Fi > Network Details.
      • Note the IP Address (e.g., 192.168.x.x).
    • Open a terminal on your laptop and execute:
     adb pair <PHONE_IP>:<PAIRING_PORT>
    

    Replace <PHONE_IP> with your phone's IP and <PAIRING_PORT> with the pairing port displayed in Developer Options. Follow the on-screen instructions to complete pairing.

  4. Connect to your phone:

   adb connect <PHONE_IP>:<ADB_PORT>

Replace <ADB_PORT> with the debugging port (usually 5555).

Step 2: Port Forwarding Using ADB

To allow your phone to access the server running on your laptop:

  1. Forward Ports: Use the following ADB command to forward your phone's port (e.g., 8080) to your laptop's port 80:
   adb reverse tcp:8080 tcp:80

This maps your phone’s port 8080 to your laptop’s port 80.

  1. Access the Server from Your Phone:
    • Open a browser on your phone.
    • Enter the URL: http://127.0.0.1:8080.
    • This redirects traffic from your phone’s port 8080 to the laptop’s port 80.

Step 3: Verify via Chrome DevTools

  1. Open Chrome on your laptop.
  2. Navigate to: chrome://inspect/#devices.
  3. Ensure your phone is listed under Remote Devices.
  4. Use the Port Forwarding option in DevTools if needed to manage ports.

Alternative: Direct Access Without ADB

If you don’t want to use ADB:

  1. Ensure your laptop and phone are on the same Wi-Fi network.
  2. Find your laptop’s local IP address:

    • On Windows:
     ipconfig
    

    Look for the IPv4 address under your active network.

    • On macOS/Linux:
     ifconfig
    
  3. On your phone, enter your laptop’s IP address with port 80 in the browser:

   http://192.168.x.x

Troubleshooting

  • ADB Connection Issues:

    • Ensure your phone is on the same network as your laptop.
    • Restart ADB server:
    adb kill-server
    adb start-server
    
  • Port Forwarding Not Working:

    • Check if your server is running properly on port 80.
    • Verify your phone’s local port (127.0.0.1:8080) is forwarded to the laptop.

By following these steps, you can easily access your laptop’s server from your phone wirelessly!

Featured ones: