Feb 1, 2025

Access a Mac dev server from iOS using localhost

During development, you may want to run a local server on your Mac and verify behavior from a mobile device.

If you start the server bound to 0.0.0.0, you can reach it from the same LAN using a private IP address (192.168.0.0/16). However, depending on security settings, only localhost may be allowed and private IP access may be blocked.

In that case, establish SSH port forwarding between the iOS device and your Mac so that the iOS device can access the Mac’s local environment using the localhost address directly.

Connection steps

1. Enable “Remote Login” in macOS Sharing

Open System Settings, go to Sharing, and turn on “Remote Login”. This allows connecting to the Mac over SSH.

macOS Sharing settings

2. Install WebSSH (SSH client) on iOS

Install WebSSH from the App Store. With its VPN-Over-SSH feature, other apps like Chrome and Safari can keep using the port‑forwarding setup.

Install WebSSH

3. Configure port forwarding

Launch WebSSH and configure as follows.

  1. Enter the information confirmed in macOS Sharing:
    • Hostname
    • Username
    • Password
    • Private IP address
  2. Port Forwarding settings
    • Example: if your Mac uses localhost:3000, enter 3000:localhost:3000.
  3. Enable VPN-Over-SSH
    • This keeps the SSH tunnel active while using other apps.
WebSSH port‑forwarding settings

4. Verify port forwarding

Once configured, open WebSSH on the iOS device and check that the port‑forwarding settings are applied.

Verify the configuration