How to access mac localhost site from iPhone?

Use case:

By using your awesome Mac you are building a web app. The app is doing all the fantastic things. Now you need to test something on an iPhone device.

Your application is running on localhost inside the Mac. Now, how do we browse Mac’s localhost site on the iPhone?

Solution

Well, if your Mac and iPhone are connected with the same wifi then it’s very easy to do.

Do the following steps on your Mac:
1. Open System Preferences
2. Click on Network
3. This will show a screen like below:
mac network screen
4. Get the IP address
5. On the mac, which port your app is running? Say app is running on port 8080

Now go to the iPhone device and check the iPhone browser with the following URL:

192.168.1.241:1448