Your API returns 200 OK on your laptop. You open the same endpoint from your Android phone with a free VPN connected, and the request hangs. Meanwhile, the phone can browse the web just fine.
Before you change your app’s base URL or start editing firewall rules, watch the terminal where the API is running. Does a GET /health line appear when you refresh the page on the phone? That one observation tells you whether to investigate how the request reaches the laptop or what happens after it arrives.
Here’s a small experiment you can run on your own Wi-Fi. You’ll use one endpoint, one physical Android phone, and two network paths. The second path, over USB, also gives you a way to keep developing if Wi-Fi is still giving you trouble.
Give the phone something recognizable to request
Save this as health.cjs on your laptop. It uses Node.js without any dependencies.
const http = require('node:http');
const server = http.createServer((req, res) => {
console.log(new Date().toISOString(), req.method, req.url);
if (req.method !== 'GET' || req.url !== '/health') {
res.writeHead(404).end();
return;
}
res.writeHead(200, {
'Content-Type': 'application/json',
'Cache-Control': 'no-store'
});
res.end(JSON.stringify({ service: 'laptop-api', time: Date.now() }));
});
server.listen(3000, '0.0.0.0');
Run node health.cjs. In a second terminal, check the endpoint:
curl -i http://127.0.0.1:3000/health
Look for 200 OK, the service name laptop-api, and a fresh GET /health in the server terminal. The changing time value gives you a way to recognize a fresh response on the phone, too.
The address in listen() matters. Binding to 127.0.0.1 would let this laptop test pass while preventing a direct connection from another device. 0.0.0.0 tells Node to listen on all the laptop’s IPv4 interfaces, including Wi-Fi. Use this temporary server on a network you control and stop it with Ctrl+C when you’re done.
Establish the Wi-Fi baseline
Find the IPv4 address listed for the laptop’s active Wi-Fi connection. Suppose it’s 192.168.1.42. On the laptop, try the LAN address before picking up the phone:
curl -i http://192.168.1.42:3000/health
Replace the example address with yours. If this request fails while 127.0.0.1 works, fix the address or listener first. On a machine with Docker, a VPN, and Wi-Fi running together, it’s easy to copy an address from the wrong interface.
Now connect the physical phone to the same trusted Wi-Fi network. With the phone’s VPN disconnected, enter http://192.168.1.42:3000/health in its browser, again substituting the laptop’s address. Include http:// because the sample server speaks plain HTTP.
Three details can save you a surprising amount of debugging:
-
localhoston the phone means the phone itself. It will become useful in the USB test below. -
10.0.2.2is a special address the Android Emulator uses to reach its host. A physical phone on Wi-Fi needs the laptop’s LAN address. - A successful request from the laptop to its own LAN address checks the address and listener. The phone’s request is the one that tests incoming traffic from another device.
Record whether the phone displays laptop-api and whether the server logs GET /health. Ignore incidental browser requests such as GET /favicon.ico.
Change one thing: connect the VPN on the phone
Leave the server running. Keep the same phone, browser tab, Wi-Fi network, port, and numeric IP address. Connect the VPN on the phone, wait until it reports connected, then refresh. If the page loads, check that the time value changes.
| VPN off | VPN on | What to investigate |
|---|---|---|
| Loads | Times out | If only the first request appears in the server log, inspect the VPN’s handling of local network traffic. |
| Times out | Times out | Start with the LAN address, laptop firewall, and Wi-Fi client isolation. The baseline already fails. |
| Loads | Loads | The browser can reach this endpoint in both states. If the app still fails, inspect the app’s request. |
| Times out | Loads | Repeat in reverse order and check the log timestamps. Confirm the phone stayed on the same Wi-Fi and used the same address. |
A repeatable off/on/off result is more informative than one timeout. If the first and third requests arrive and the middle one never appears, you have a specific question to investigate: what happens to traffic addressed to the laptop’s private IP while this VPN configuration is active?
Look in the VPN client for a setting concerning local network or LAN access. If your setup permits changing it, change only that setting and repeat the request with the VPN connected. The word free describes the plan. It doesn’t tell you how the client handles a local destination.
There’s also a useful distinction between Android Private DNS and a VPN connection. This test uses a numeric IP, so the browser has no laptop hostname to resolve. If the numeric address works but your usual development hostname fails, you’ve found a reason to investigate name resolution separately.
Let the server log decide the next step
No request reaches the server, even with the VPN off. Check whether the phone is on a guest network. Two devices can have internet access from the same Wi-Fi network while the access point prevents them from reaching each other. Also check whether the laptop firewall permits incoming TCP connections to port 3000 on your development network. There’s no need to disable the entire firewall to test one port.
The server logs GET /health, but the phone shows an error. The request reached the Node process. Record the browser’s exact error and inspect the response. A line in the server log establishes arrival, but it can’t tell you whether the phone received and accepted the complete response.
The phone’s browser works, but your app fails. Compare the app’s actual scheme, host, port, and path with the working browser address. Check Logcat for the first underlying error. For example, CLEARTEXT communication ... not permitted points to the app’s HTTP policy. Changing VPN settings won’t make an HTTP endpoint satisfy an HTTPS requirement. Use an appropriate development HTTPS endpoint or a debug-only policy scoped to your test setup.
Use USB to keep working
If your immediate goal is to test an app feature against the laptop API, Android’s adb reverse gives you another path. With a USB mapping in place, a connection to a port on the phone can reach a port on the laptop. You can leave the phone’s VPN connected for this comparison.
With Android SDK Platform-Tools installed, enable USB debugging on the phone, connect it using a data-capable cable, and approve the debugging prompt for your development machine. Run:
adb devices
Once your phone appears with the state device, create the mapping. These commands assume it’s the only connected Android target.
adb reverse tcp:3000 tcp:3000
adb reverse --list
Now open http://127.0.0.1:3000/health on the phone. This is the point where using loopback becomes intentional. ADB listens on device port 3000 and forwards the connection to port 3000 on the development machine.
If you see laptop-api with a fresh timestamp, you can use that address in your app’s debug configuration, subject to the app’s HTTP policy. A successful USB request shows the phone can reach the service over ADB. The original Wi-Fi route is still a separate question.
When you finish, remove the mapping:
adb reverse --remove tcp:3000
The most useful bug report from this exercise is only a few lines long. Record the address the phone requested, whether the VPN was connected, whether the server logged the request, and whether USB worked. “Wi-Fi succeeds with the VPN off, no request arrives with it on, and USB succeeds in both states” gives the next developer a precise place to start.
Top comments (0)