How to connect to localhost on Mac from iPhone
Introduction
This article shows how to connect to localhost on Mac from iPhone and some tips.
Conditions
How to connect it
- Set up the localhost server on a mac
- Confirm the access to the "localhost:{PortNumber}" by safari or something.
- Check the mac's domain name from [Preference] - [sharing] ({YOUR_PC_NAME}.local)
- Access the domain({YOUR_PC_NAME}.local) from iPhone by safari or something.
Finished!
Tips1
If the localhost uses the port number 80 or some another famous ports, the inbound request will be refused by mac native firewall.
To solve the problem, turn off the native firewall from [Preference] - [Security&Privacy].
But, as you know, it's not recommended.
Tips2
If you would like to connect the mac as API Server from iOS app, you need to turn off the ATS(App Transport Security) on the Xcode.
But, if you can access the server from https connect, it's not a problem.