If you're doing any kind of web development work these days, you probably need your website or app to run on mobile phones.
By default, your iPhone or iPad won't be able to access an app that's running on localhost on your desktop (unless you're running the simulator).
If both your computer and your phone are in the same network however, you can take your phone and navigate to the local IP address of your computer.
Step 1: Get IP Friend for macOS (Free)
Go the Mac App Store and download IP Friend. Then, go ahead and open the app.
Step 2: Copy Your IP Address
Click the "IP" icon in your menubar to copy your IP address.
If you have your localhost address in your clipboard (e.g. http://localhost:3000
), you can hold
down Option ⌥ with the IP menu open to replace the "localhost" part with your IP. http://localhost:3000
then becomes something like
http://192.168.0.1:3000
.
Step 3: Paste the Address on Your Phone
macOS and iOS share a clipboard thanks to iCloud Clipboard, so you can now simply paste the IP address in Safari's address bar on your iPhone.
Don't forget to add http://
and the port if necessary!
Video Walkthrough
Watch the following video to see how easy it is to open localhost website with IP Friend: