A web app running on your laptop opens fine at localhost in your own browser, but a tablet on the same Wi-Fi often gets nothing. Two settings on the laptop decide whether other devices can reach it: the address the app listens on, and the firewall. A third thing catches people out later, because the laptop’s address and the network’s range change each time you join a different Wi-Fi.
I set this up at work so colleagues could try a web app from tablets while it ran on my laptop, first on my home Wi-Fi and then at the office.
The path a request takes
A tap on the tablet sends a request to the laptop’s Wi-Fi address, and the router passes it along. The laptop’s firewall lets the request in only if a rule allows that port from the sender’s network, and drops it otherwise. The app then answers, but only if it listens on the Wi-Fi address too. Your own browser takes a shortcut: localhost is loopback, which never leaves the laptop, so testing there proves nothing about the Wi-Fi path.
Listening on 0.0.0.0 or 127.0.0.1
When an app starts, it chooses which of the laptop’s addresses to accept connections on.
| The app listens on | Who can connect |
|---|---|
127.0.0.1, also called localhost | Only programs on the same laptop |
0.0.0.0 | Any of the laptop’s addresses, so other devices too, if the firewall lets them in |
Development servers often listen on 127.0.0.1 by default, so a half-finished app isn’t exposed to the network. Most have an option to change it, often called --host. To see what is listening, run ss -ltn. The “Local Address:Port” column shows 127.0.0.1:8080 for laptop-only, or 0.0.0.0:8080 for every address.
Which of your addresses to give out
A laptop has one address per network connection, so hostname -I usually prints several. Only one of them is on the Wi-Fi.
| Connection | Typical name | Reachable from the tablet? |
|---|---|---|
| Loopback | lo, always 127.0.0.1 | No. On every device it means “this same machine” |
| Wi-Fi card | Starts with wl, such as wlan0 or wlp2s0 | Yes. This is the address to hand out |
| VPN tunnel | wg0 for WireGuard, tun0 for OpenVPN | No |
| Docker bridge | docker0 | No. It only connects the laptop to its own containers |
ip -4 route show dev <wifi-name> proto kernel prints the Wi-Fi’s network range first and the laptop’s own address after src, for example 192.168.1.0/24 proto kernel scope link src 192.168.1.23.
The number after the slash is the size of the network. /24 fixes the first three numbers, so the network spans 256 addresses, from 192.168.1.0 to 192.168.1.255. /22 fixes two bits fewer and spans 1,024 addresses, four blocks of 256. Every device that joins the Wi-Fi gets an address inside that range.
The firewall rule belongs to the network
A firewall such as ufw blocks new incoming connections unless a rule allows them (see ufw-firewall and vpn-how-it-works). The tidy rule for a demo names both the port and the range, in the form sudo ufw allow from <range> to any port <port> proto tcp. Any device on this Wi-Fi gets in, and nothing outside it does.
Because the rule names a range, it belongs to one network, not to the laptop.
| What | Changes between networks? | Why |
|---|---|---|
| The laptop’s Wi-Fi address | Yes | Each router hands out addresses from its own range |
| The range in the firewall rule | Yes | The home rule doesn’t match the office’s addresses, so the tablet is blocked until you add a rule there |
| The port, the app and its accounts | No | They live on the laptop |
So each session has the same rhythm. Read this network’s address and range, add a rule for that range, and delete the rule when you leave. sudo ufw status numbered shows each rule’s number, and sudo ufw delete <number> removes that one rule.
When the tablet can’t connect
| What you see | Most likely cause |
|---|---|
| The page never loads | No firewall rule for this network’s range, or the two devices are on different Wi-Fi networks |
| Nothing connects on a guest or office network | Client isolation: the network stops devices talking to each other. A phone hotspot makes a small private network of its own |
| The login page loads, but logging in fails | The network is fine. Check the account, and that you opened the right port |
| It worked, then stopped | The laptop slept, changed network or got a new address |
Plain HTTP sends passwords unencrypted
A development server usually speaks HTTP, not HTTPS, so anything typed into it crosses the Wi-Fi unencrypted. Give testers throwaway accounts, log in yourself through
localhost, and delete the firewall rule when the demo ends, especially on networks you don’t control.