Why localhost does not work from your phone
http://localhost:5173 on your phone asks the phone for a server on port 5173. There is none. localhost and 127.0.0.1 always point at the device you type them on. To reach the Mac, the phone needs the Mac’s address on the network you share, and the Mac’s server needs to be listening on that address rather than only on the loopback interface.
Those are the two fixes, plus one firewall prompt. Everything else is checking that the phone and the Mac are actually on the same network.
Find your Mac’s address
On Wi-Fi the interface is usually en0:
It prints something like 192.168.1.24. If it prints nothing, try en1, or list every interface with an address:
System Settings > Wi-Fi > Details also shows it under IP address. Addresses starting with 192.168., 10., or 172.16. through 172.31. are the private ones you want. An address starting with 169.254. means the Mac did not get one from the router, so the network itself is the problem.
The Mac’s local hostname works too and survives address changes: System Settings > General > Sharing shows it as <name>.local, so http://ardas-macbook.local:5173 resolves on most phones via Bonjour.
Bind the server to all interfaces
Most dev servers listen on localhost only by default. That is deliberate: it keeps your half-finished app off the coffee shop network. To share it, tell the server to listen on all interfaces, which is 0.0.0.0:
Vite:
vite --hostor--host 0.0.0.0, orserver.host: trueinvite.config.Next.js:
next dev -H 0.0.0.0.Create React App / webpack-dev-server:
HOST=0.0.0.0 npm start, ordevServer.host: '0.0.0.0'.Expo:
npx expo startalready serves on the LAN; the QR code in the terminal opens it in Expo Go.Rails:
bin/rails server -b 0.0.0.0.Django:
python manage.py runserver 0.0.0.0:8000.Python one-liner:
python3 -m http.server 8000 --bind 0.0.0.0.Flask:
flask run --host=0.0.0.0.
Then open http://192.168.1.24:5173 on the phone. Vite prints the network URL for you once --host is set; most other servers print only the local one, so build it yourself from the address above.
Hot reload over the network works for Vite and Next out of the box. If HMR connects to localhost and fails on the phone, set the HMR host explicitly (server.hmr.host in Vite).
When it still fails
Work down this list:
Same network, really. A phone on cellular, or on the guest Wi-Fi while the Mac is on the main one, cannot reach the Mac. Turn off cellular data on the phone for a moment to be sure.
The macOS firewall. The first time a server binds to all interfaces, macOS may ask “Do you want the application to accept incoming network connections?”. Click Allow. If you dismissed it, System Settings > Network > Firewall > Options lists the apps;
nodemust be allowed, or turn off “Block all incoming connections”.A VPN on either device. Many VPN clients route all traffic through the tunnel and block LAN access. Disconnect to test.
Client isolation. Office and hotel networks often block device-to-device traffic. There is no fix on the Mac side; use your phone’s hotspot and connect the Mac to it.
Wrong interface. If the Mac has Ethernet and Wi-Fi,
en0may be the one the phone cannot reach. Use the address from the interface that shares the phone’s network.Still listening on localhost. Check with
lsof -nP -iTCP:5173 -sTCP:LISTEN.*:5173or0.0.0.0:5173means all interfaces;127.0.0.1:5173or[::1]:5173means localhost only, and the--hostflag did not take.
For a quick check that the server is reachable at all, run curl http://192.168.1.24:5173 from a second Mac or from the phone’s browser, which skips any app-specific issue.
If you need someone outside your network to see it, a LAN address will not do. That is what tunnels like ngrok, cloudflared, or ssh -R are for, and they are a different guide.
Doing this in Room Service
Room Service’s Dev Ports list shows every server your user is listening on, with its project. Each row also says how it is bound. A server on localhost only shows the hint “This server is listening on localhost only. Start it with --host 0.0.0.0 to share it on your LAN.” A server on all interfaces gets a LAN badge with “Reachable on LAN at” the address Room Service resolved, a Copy LAN URL action, and a QR code you scan from the phone instead of typing the address. When the Mac changes network, the LAN links update and the app tells you.
The list is on the Home dashboard, in the menu bar popover, and in the Command Palette (search “localhost”). roomservice ports prints the same table in the terminal.
Seeing the list, Open, Copy LAN URL, and the QR code are free. Stopping a server is the only Pro action on the row.
