Access localhost from phone
Your phone cannot use localhost to reach your computer. Use the computer LAN IP address plus the same port instead.
Fast checklist
- 1 Put the phone and computer on the same Wi-Fi network.
- 2 Find the computer LAN IP address.
- 3 Start the dev server so it accepts network connections when your framework requires it.
- 4 Open http://LAN-IP:PORT/ on the phone.
- 5 If it fails, check firewall rules and whether the server is bound only to localhost.
Quick diagnostic checks
ipconfig getifaddr en0Use the returned address on the phone, for example http://192.168.1.24:3000/. Do not type localhost on the phone.
npm run dev -- --host 0.0.0.0Frameworks differ, but the idea is the same: the server must listen beyond the computer-only loopback interface.
http://LAN-IP:PORT/If this fails while localhost works on the laptop, check Wi-Fi isolation, firewall prompts, VPNs, and the framework host setting.
Live request check
What this page sees
HTTP request headers
Sensitive headers such as cookies and authorization tokens are filtered before display.
Why localhost fails on a phone
Localhost always means the device currently making the request. On your phone, localhost means the phone, not your laptop.
The right mental model
Use localhost only on the machine running the server. Use a LAN IP, tunnel, or deployed URL for other devices.
Framework host settings matter
Opening the laptop LAN IP is not enough if the dev server is bound only to localhost. Vite, Next.js, Angular, Flask, Django, and similar tools each have a host option for network access.
- Use the same port that works on the laptop.
- Keep phone and laptop on the same non-isolated network.
- Accept the operating system firewall prompt for the dev server when needed.
Related localhost guides
localhost:5173
Use localhost:5173 for Vite-style development servers and troubleshoot when the browser cannot reach the local app.
Port guidelocalhost:3000
Open localhost:3000, learn which development servers commonly use port 3000, and fix connection errors quickly.
Comparisonlocalhost vs 127.0.0.1
Compare localhost and 127.0.0.1, understand loopback addresses, and learn when one works while the other fails.
Developer toolLocalhost URL Builder
Build localhost URLs with the right protocol, host, port, and path, then compare localhost, 127.0.0.1, and LAN IP patterns.
FAQ
Can 127.0.0.1 on my phone reach my laptop?
No. 127.0.0.1 is also loopback for the current device. Use the laptop LAN IP address instead.
Why does my LAN URL still fail?
The server may be bound only to localhost, the firewall may block inbound traffic, or the phone and computer may be on isolated networks.
What is the fastest way to verify a localhost explanation?
Test the exact host, port, and path in the browser, then check the terminal or service logs. Localhost problems are easiest to solve when the URL and the running process match.
When should I use a LAN IP instead of localhost?
Use a LAN IP when another device, browser profile, virtual machine, or container needs to reach a service running on your computer.
Can a coding assistant give the wrong localhost URL?
Yes. Tutorials and coding assistants often assume a default port. Always compare the suggested URL with the actual URL printed by your local development server.