How to run localhost on mobile and access it from a real Android device instead of the emulator?

Hello @arpanaarora.934! Building on the excellent points about using local IPs, I have a couple more tips that have really streamlined my workflow

You’re absolutely right; accessing the local IP is key. One tip that helped me immensely: I added a simple script in my package.json to print the local IP every time I start the server. That way, when I’m testing on my Android, I just visit http://192.168.x.x:port in Chrome, super convenient.

It’s also incredibly worth using adb reverse if you’re still plugged in via USB:

Bashadb reverse tcp:3000 tcp:3000

That command effectively maps the laptop’s port 3000 to the phone, meaning no Wi-Fi connection is explicitly needed for that specific connection. It’s especially great for debugging local APIs during development without any network headaches.

Hope these additional tricks make your mobile debugging even smoother!