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
- ADB (Android Debug Bridge) installed on your laptop.
- Both your laptop and phone must be on the same Wi-Fi network.
- A server running on your laptop's port 80 (e.g., a local web server).
Step 1: Enable Wireless Debugging on Your Phone
-
Enable Developer Options on your Android phone:
- Go to Settings > About Phone.
- Tap Build Number 7 times to unlock Developer Options.
Navigate to Developer Options and enable Wireless Debugging.
-
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. - Get your phone's IP address:
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:
-
Forward Ports:
Use the following ADB command to forward your phone's port (e.g.,
8080
) to your laptop's port80
:
adb reverse tcp:8080 tcp:80
This maps your phone’s port 8080
to your laptop’s port 80
.
-
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 port80
.
Step 3: Verify via Chrome DevTools
- Open Chrome on your laptop.
- Navigate to:
chrome://inspect/#devices
. - Ensure your phone is listed under Remote Devices.
- 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:
- Ensure your laptop and phone are on the same Wi-Fi network.
-
Find your laptop’s local IP address:
- On Windows:
ipconfig
Look for the IPv4 address under your active network.
- On macOS/Linux:
ifconfig
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.
- Check if your server is running properly on port
By following these steps, you can easily access your laptop’s server from your phone wirelessly!
Top comments (2)
What scenarios would we want to use adb to access a server over using the IP:port directly?
i recently implemented api fetched website that has PWA, you cant test your PWA application in your phone, unless you have https connection. so by doing this i was able to test my PWA feature without having to do any messy stuff...