Phones and public links

A .test name only resolves on your Mac: /etc/hosts is yours, and your phone never reads it. The Network panel gets around that in two ways. One opens a site to devices on your Wi-Fi or Ethernet. The other gives it a temporary public address anyone can open.

Network mode

Sites → Network has one switch at the top. When it is off, sites only open on this Mac. When it is on, the sites you have shared can be reached from other devices on the same network.

Each shared site gets a port of its own, starting at 8100, so no DNS is involved at all:

http://192.168.1.24:8100

Press Share on network on a site and the address appears under it. Sharing a site switches network mode on if it was off.

Switching network mode off closes every LAN port at once, but the list of shared sites is kept. Switching it back on brings them all back on the same ports.

Opening it on your phone

Your phone has to be on the same network as the Mac. Under Address for phone links, pick which of the Mac's addresses the links use:

Wi-Fi or Ethernet. Each connected interface is listed with its IP. Use the one your phone is on. The address changes when you switch networks, and the panel follows it.

Bonjour name. your-mac.local stays the same across networks. iPhones resolve it; some Android phones cannot.

Press QR next to an address and point the phone's camera at it. Copy and Open are there too.

Public URL gives a site a temporary https://….trycloudflare.com address through a Cloudflare quick tunnel. It works from anywhere, not just your network. Use it to show a client your work, test on mobile data, or receive a webhook.

  • No account is needed. It uses cloudflared, and the panel offers to install it through Homebrew if it is missing.
  • Anyone with the link can open the site, so Vhostly asks before creating one.
  • The link stays up until you press stop or quit Vhostly. The next one gets a different address.
  • While a link is up, a banner above Virtual Hosts names the site and its address, with Stop sharing next to it, so a public site is never out of sight.
  • If Vhostly crashes with a link still up, it finds that tunnel on the next launch and lists it again. One whose address it cannot read is stopped.
  • Nothing changes in Apache. cloudflared connects to Apache on this Mac and sends the site's .test name as the host, so the right site answers.

A new address can take a few seconds to resolve worldwide. The panel waits for that before showing it, so the link works as soon as you see it.

HTTPS-only sites

A site with Force HTTPS on still works both ways. Its LAN copy answers on plain HTTP, because a phone cannot trust a certificate issued for myapp.test on an IP address. The public link connects to the site's :443 vhost and is served over Cloudflare's own HTTPS.

Keeping things in step

The LAN copy of a site follows the site:

  • Editing a site updates its shared copy.
  • Disabling or deleting a site stops sharing it and closes its public link.

The Virtual Hosts list marks shared sites with LAN :8100 and sites with a public link with PUBLIC.

When the phone cannot connect

Is it on the same network? Guest Wi-Fi and some office networks keep devices apart. A public link works around that.

The macOS firewall. If it is on, the panel says so. Allow incoming connections for httpd under System Settings → Network → Firewall → Options.

The page redirects to .test. Apps that build links from a fixed site URL send the phone back to a name it cannot resolve. WordPress uses siteurl and Laravel uses APP_URL. Point that setting at the shared address while you test.

What it writes

Shared sites live in /opt/homebrew/etc/httpd/extra/httpd-vhosts-lan.conf. Each one is a Listen line and a copy of the site's :80 block moved to its port. The network mode switch is the Include line for that file in httpd.conf: it is added when the switch is on and removed when it is off. See what Vhostly writes.