# Open localhost on your phone: URL builder Source: https://portlivo.com/guides/localhost-url-builder · Updated 2026-12-02 Your app opens on the Mac, but the same localhost address fails on your phone. Build the address for the Mac on your local network, then check that the server accepts connections from another device. **In short:** On a phone, localhost points to the phone itself. Use your Mac’s private network address and the server’s actual port, such as http://192.168.1.20:5173/. The builder below prepares that address. It does not test whether the server is listening or reachable. ## 1. Find the Mac’s address and server port Open System Settings → Wi-Fi → Details for the connected network and find its IP address. For Ethernet, use that connection’s details instead. Enter the private IPv4 address into the builder; 192.168.1.20 is only an example. Read the address printed by your dev server. Use its actual port, including any automatic fallback from 5173 to 5174. Put the page path, such as /dashboard, in the last field. Don’t enter a router’s public address or 0.0.0.0 as the Mac’s address. ## 2. Let the server listen on the network Vite normally listens on localhost. If your package.json dev script runs Vite, start it with: ``` npm run dev -- --host 0.0.0.0 ``` This changes where the dev server listens; it doesn’t make 0.0.0.0 the address to type on a phone. Use the private address from step 1. Vite documents this under [server.host](https://vite.dev/config/server-options#server-host). Use a trusted network and stop the server when finished; you don’t need router port forwarding for this. ## 3. Open the built URL on your phone 1. Connect the phone and Mac to the same reachable local network. Guest Wi-Fi can isolate devices even when the network names match. 2. Copy the generated URL to the phone using your usual sharing method, then open it in the browser. 3. If it times out, check the Mac’s address, the actual port, the server host binding and whether the firewall allows that server. Keep the firewall enabled; investigate the relevant app rule. A successful URL calculation is not a successful connection test. This page deliberately makes no requests to your private network. ## The page loads, but API calls still fail A frontend can load from the Mac while still requesting http://localhost:3001/api. On the phone that request goes to the phone, not the Mac. Check the browser’s network error and your API base URL. Use an appropriate development proxy or a reachable backend address; changing the frontend URL alone doesn’t fix API routing. Follow the [full phone-testing guide](https://portlivo.com/guides/test-local-dev-server-on-phone) for the Vite proxy example, or [share localhost](https://portlivo.com/guides/share-localhost-mac) if you need a separate remote-access workflow. For the meaning of loopback addresses, see [MDN’s explanation](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Local_network_access). ## When the port belongs to a different project If you have several servers running, verify which project owns the port before opening it on a phone. [See every dev server on your Mac](https://portlivo.com/guides/see-running-dev-servers-mac), or use [Portlivo’s sharing feature](https://portlivo.com/features/share) for the existing app workflow. The free builder above works without installing Portlivo. ## Questions people ask **Can I open localhost on my phone?** Localhost refers to the device opening the address. To reach a server on your Mac, use the Mac’s private network address and the server’s actual port, with the server listening beyond loopback. **Does this tool scan my Wi-Fi or create a tunnel?** No. It only constructs an HTTP or HTTPS URL from your entries, locally in the browser. Network reachability and certificates need to be configured separately.