How to open localhost on your phone
iPhone and Android. Updated
On a phone, localhost means the phone itself, so you need your computer's Wi-Fi address instead, such as http://192.168.1.20:5173. That's enough to check a layout. But a plain http:// address isn't a secure context, so the camera, microphone, WebCrypto, service workers and the clipboard API don't work there. For those you need HTTPS, or, on Android, Chrome's port forwarding.
The quick way: your computer's Wi-Fi address
- Make your dev server listen on the network, not only on your computer. Vite:
npx vite --host, orserver.host: truein the config. Next.js already listens on the network. Most other servers have a host option. - Find your computer's address. Vite and Next.js print it as "Network". On a Mac:
ipconfig getifaddr en0. On Windows:ipconfig, then the IPv4 address of your Wi-Fi adapter. - With the phone on the same Wi-Fi, open
http://<that address>:<port>.
If the page doesn't load:
- Firewall. macOS asks whether to accept incoming connections for
node; Windows blocks them on networks marked Public. - The network. Guest and office Wi-Fi often keep devices from seeing each other (client isolation). A VPN on either device can do the same.
- The dev server. Next.js 16.2 and later loads the page but blocks hot reload from your Wi-Fi address until you add it to
allowedDevOrigins. See Next.js on your phone. Vite allows IP addresses but blocks tunnel hostnames: see Vite's "Blocked request".
What breaks on a plain Wi-Fi address
Browsers enable powerful features only in a secure context: HTTPS, or localhost itself. Your Wi-Fi address is neither, so on the phone:
| Feature | On http://192.168.x.x |
|---|---|
Camera and microphone (getUserMedia) | navigator.mediaDevices is undefined |
WebCrypto (crypto.subtle) | Undefined, so login, encryption and hashing code fails |
| Service workers, offline mode, installing as an app | Not available |
| Clipboard API | navigator.clipboard is undefined |
The same code works on your computer at localhost, which is why these bugs show up only on the phone. You can check with window.isSecureContext. More in camera or microphone not working on a phone.
Getting a secure context on the phone
Android: Chrome port forwarding
Chrome on Android can reach your computer's localhost over USB, and it treats that as secure:
- Turn on USB debugging on the phone (Developer options) and connect it to the computer.
- In desktop Chrome, open
chrome://inspect, choose Port forwarding, and forward your port (for example 5173) tolocalhost:5173. - On the phone, open
http://localhost:5173in Chrome.
The same page gives you DevTools for the phone. It needs the cable and Chrome on both sides, and there's no iPhone equivalent.
A local certificate (mkcert)
mkcert creates a certificate authority on your computer and a certificate for your Wi-Fi address. Serve your app with that certificate, then install the authority (rootCA.pem from mkcert -CAROOT) on the phone. On an iPhone:
- Install it in Settings, under General, VPN & Device Management.
- Turn on full trust in Settings, under General, About, Certificate Trust Settings.
Android has its own path for installing a CA certificate in Settings, and some browsers ignore user-installed authorities. It's free and stays on your network. You do it on every test device, and re-issue the server certificate when your address changes.
A public tunnel (ngrok, Cloudflare Tunnel)
A tunnel gives your local server a public HTTPS address that works on any network, including mobile data. cloudflared tunnel --url http://localhost:5173 prints a random trycloudflare.com address with no account. ngrok's free plan shows a warning page to browsers before your app. The address is public, so anyone with the link can open your work in progress. Vite and Next.js also need the tunnel's hostname in their allowed lists.
Tondavo
Run npx tondavo in your project and point the phone's camera at the QR code. The phone opens your app at https://dev.tondavo.com, a real secure context (service workers are the exception: the edge refuses them, because all sessions share that address; test those with mkcert). Anyone else who opens that address is stopped at the edge. Nothing is installed on the phone, it works on mobile data, and Vite and Next.js need no config changes. Tondavo also passes on what the phone sees: errors, failed requests and taps that hit nothing appear in your terminal, and your AI coding agent can read them, see the screen and tap through the page.
| Wi-Fi address | Chrome port forwarding | mkcert | Public tunnel | Tondavo | |
|---|---|---|---|---|---|
| Best choice when | You only check layout | You test on Android and want full DevTools | Traffic must stay on your network | You need a link anyone can open, or a webhook | You test device APIs on your own phone, or want your agent to use it |
| Secure context | No | Yes | Yes | Yes | Yes |
| iPhone | Yes | No | Yes, after trusting a certificate | Yes | Yes |
| Android | Yes | Yes | Yes, after installing a certificate; some browsers ignore it | Yes | Untested |
| Needs | Same Wi-Fi | USB cable, Chrome | Setup per device | Account or random URL | Node.js 22 |
| Who can open it | Your network | That phone | Your network | Anyone with the link | Only the paired phone |
| Errors from the phone | Separate tool | Chrome DevTools | Separate tool | Separate tool | Terminal and agent tools |
| Traffic passes a third party | No | No | No | Yes, the tunnel provider | Yes, Tondavo's edge on Cloudflare |
Seeing errors from the phone
- Android:
chrome://inspecton the computer, with the phone on USB debugging. - iPhone: turn on Web Inspector in Settings, Apps, Safari, Advanced. Connect the phone to a Mac and open the page from Safari's Develop menu. There's no Apple version for Windows or Linux.
- Tondavo: errors arrive in your terminal and in your agent's tools. It's tested on macOS with iPhone Safari and needs only Node.js 22. Android is untested.
To try it: npx tondavo. See Getting started.