kayasa kayasa - 2 months ago 12x
iOS Question

Connect to Node.js Express from iPad

I am developing an Ionic application for iPad. The app is supposed to connect to Express running on Mac.

I have connected the iPad with this Mac using a usb cable. Now, in order to check that I can access node server from iPad, I am doing the following in Chrome on iPad

http://<mac ip>:<node server port>

How, this returns a page not found. The same url works when I run it directly on the Mac.

Given the Mac and iPad are connected by the usb, how can I access node server running on mac from iPad? I was hoping that something like would work, but that is not the case. Even giving the IP of Mac does not work.


the network address which is the same as localhost is bound to the particular hardware device - i.e. if you were running a server on the iPad, you could access that server from other applications on iPad through that address

to connect to a different device, you need to know its public IP address and/or hostname and both devices need to be accessible via connected networks (e.g. on the same network or the same VPN)

you can find out the hostname of your Mac by running the command hostname in Terminal

assuming the networks and firewalls are set up appropriately, you can connect from the iPad to http://hostname_found_on_mac:3000/