- DevMirror
- Any server
How to open localhost on your phone
Your site runs fine at localhost:3000 on your computer, but your phone can't open it. Here's why, and four ways to test your local site on a real Android phone or iPhone.
Quick answer
localhost on your phone means the phone itself. To open a site running on your computer:
- Start your dev server so it listens on the network (
0.0.0.0or--host). - Find your computer's local IP address, such as
192.168.1.14. - Put your phone on the same Wi-Fi.
- Open
http://YOUR-IP:PORTin your phone's browser.
Why localhost doesn't work on your phone
localhost and 127.0.0.1 are loopback addresses: they always mean "this device". On your computer they point at your computer. On your phone they point at the phone, which isn't running your dev server, so you get "This site can't be reached".
There's a second catch. Many dev servers only listen on 127.0.0.1 by default, so even with the right IP they refuse connections from other devices. You need to fix both.
Step 1: Make your dev server listen on the network
Binding to 0.0.0.0 tells the server to accept connections on every network interface, including your Wi-Fi. Here's the flag for common tools:
| Tool | Command |
|---|---|
| Vite, SvelteKit, Astro | npm run dev -- --host |
| Next.js | npm run dev -- -H 0.0.0.0 (often already on) |
| Angular | ng serve --host 0.0.0.0 |
| VS Code Live Server | Usually works as-is on port 5500 |
| Django | python manage.py runserver 0.0.0.0:8000 |
| Flask | flask run --host=0.0.0.0 |
| FastAPI (Uvicorn) | uvicorn main:app --host 0.0.0.0 |
| Rails | rails s -b 0.0.0.0 |
| PHP built-in server | php -S 0.0.0.0:8000 |
| Python static files | python -m http.server 8000 (all interfaces by default) |
| Express / Node | app.listen(3000) listens everywhere, unless you passed 'localhost' as the host |
Only do this on networks you trust. Anyone on the same Wi-Fi can reach your dev server while it's bound to 0.0.0.0.
Step 2: Find your computer's local IP address
| Computer | Run this | Look for |
|---|---|---|
| Windows | ipconfig | IPv4 Address under Wireless LAN adapter Wi-Fi (or Ethernet if you're wired) |
| macOS | ipconfig getifaddr en0 | Prints the address directly (en0 is usually Wi-Fi) |
| Linux | hostname -I | The first address in the list |
Your local IP almost always starts with 192.168., 10. or 172.16–172.31. Ignore addresses belonging to vEthernet (WSL/Hyper-V), Docker or VPN adapters. Your phone can't reach those.
Many dev servers print it for you. Vite and Next.js show a Network: line with the full URL.
Step 3: Open it on your phone
Connect your phone to the same Wi-Fi and type the address into its browser:
http://192.168.1.14:3000Use http://, not https://, unless you've set up HTTPS locally. Your router may give your computer a new IP later, so if a bookmark stops working, check the IP again.
Skip the IP hunt
DevMirror finds servers on common dev ports on your Wi-Fi and opens it on your Android phone in one tap.
Four ways to see localhost on a phone
| Method | Phones | Needs | Best for |
|---|---|---|---|
| DevMirror | Android | Same Wi-Fi | Everyday testing without typing IPs |
| Manual IP | Android, iPhone | Same Wi-Fi | One-off checks, iPhone |
USB (adb reverse) | Android | Cable + USB debugging | Locked-down or isolated networks |
| Tunnel (ngrok, Cloudflare Tunnel, VS Code port forwarding) | Any | Internet, often an account | Testing from another network or sharing with someone. Slower, and the URL is public |
Troubleshooting
"This site can't be reached" or it times out
Work through these in order: the server is bound to 0.0.0.0 (step 1), you're using the Wi-Fi adapter's IP (step 2), and the firewall allows the port. On Windows, allow your dev server's program (usually Node.js, Python or Visual Studio Code) on Private networks under Windows Security → Firewall & network protection → Allow an app through firewall.
Your phone and computer aren't really on the same network
Guest networks, public Wi-Fi and many office networks use client isolation, which stops devices from talking to each other. Some routers also separate their 2.4 GHz and 5 GHz networks. If you can't change the network, turn on your phone's hotspot and connect your computer to it. That works every time. A VPN on your computer can also block local traffic, so pause it while testing.
The page loads but API calls fail
If your frontend calls http://localhost:4000/api, the phone sends that request to itself. Use relative URLs (/api) with a dev proxy, or point the API URL at your computer's IP. The same goes for auth callback URLs set to localhost.
Django says "Invalid HTTP_HOST header"
Add your computer's IP to ALLOWED_HOSTS in settings.py, or use ['*'] during local development only.
Wi-Fi won't cooperate? Use USB (Android)
With USB debugging enabled and Android platform-tools installed, forward the port over the cable:
adb reverse tcp:3000 tcp:3000Now http://localhost:3000 on the phone reaches your computer. In DevMirror, enter 127.0.0.1 and port 3000. No Wi-Fi involved.
Bonus: inspect the page on your phone with DevTools
Android: enable USB debugging, plug in, and open chrome://inspect in Chrome on your computer. You get full DevTools for the page open on your phone.
iPhone: turn on Settings → Safari → Advanced → Web Inspector, connect to a Mac, and use Safari's Develop menu.