Open localhost from your phone or another computer
localhost only means “this device”. Use your computer’s IP address and start the server on all network addresses.
On your phone, localhost means the phone itself, so your computer's site will not open there. Use your computer's IP address instead, and make sure the server accepts outside connections.
Steps to open it on your phone
- Connect both devices to the same Wi-Fi.
- Find your computer’s IP address (commands below). It looks like 192.168.1.25.
- Start your server so it accepts outside connections (examples below).
- On the phone, open http://192.168.1.25:PORT with your own IP and port.
- If it hangs, allow the program through the firewall. On Windows, choose Private networks when asked.
Commands you can copy
ipconfigipconfig getifaddr en0hostname -Inpm run dev -- --hostnpm run dev -- -H 0.0.0.0python manage.py runserver 0.0.0.0:8000flask run --host=0.0.0.0If it still does not work
- Phone cannot reach it on guest Wi-Fi
- Guest networks often block devices from talking to each other. Use the main network.
- Works for you, not others
- Only do this on trusted networks. Opening a dev server to the network exposes it to everyone on that Wi-Fi.
Questions about Open from your phone
- Why does localhost not work on my phone?
- On your phone, localhost means the phone itself, not your computer. Use your computer's IP address.
- What is 0.0.0.0 for?
- Starting a server on 0.0.0.0 makes it accept connections from other devices on your network, not only from your own computer.
Free tools that help
- Subnet calculatorEnter an IPv4 address with a prefix or netmask to get the network, broadcast, host range, wildcard mask and usable hosts. Split into subnets.
- Common ports listSearch a list of common TCP and UDP port numbers: SSH 22, HTTP 80, HTTPS 443, MySQL 3306, PostgreSQL 5432 and more, with dev server ports.
Config generators for this
- WireGuard server config (wg0.conf)Set up a WireGuard VPN server on Linux with one peer, NAT and the right commands.