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.
- Find your address from the terminal
- ip -br -4 addr on Linux, ifconfig on macOS, ipconfig on Windows. See test a port and find your IP.
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
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.