my webserver software is nginx which runs very well on macbook air using mac os x 10.7.5

when i go to http://myapp.localhost on my macbook air, i can access my website perfectly which is running on localhost.

how can i access the website from my iPad? I am asking because i want to test if my website allows tablet to access just as well on desktop browsers.

i have two possible setups.

1) macbook air running HUAWEI-MOBILEModem and using INTERNET SHARING to allow the iPad to access.

2) when both macbook air and iPad are accessing the same WIFI connection.

Please provide solutions for both scenarios.

UPDATE: i have more than 1 app running on my macbook air nginx webserver.

for conveniences, let's call them


How can my iPad access the correct webapp hosted on my macbook air?


on my macbook air, i access different webapps because i edited my /etc/hosts file.

  • 1
    Are you open to solutions that let you use different ports / multiple nginx to isolate the web apps, or do you truly need one instance and have to isolate things by URL only. I've had great luck overloading the NIC to have multiple IP addresses and using xip.io to resolve to normally un-routable local addresses. – bmike Dec 4 '12 at 19:43
  • i dont mind hearing the idea, @bmike – Kim Stacks Dec 7 '12 at 7:56

In both scenarios, using the IP or machinename.local address of the Mac will only give you the default website on that Mac. Your web apps are all at the top-level so Nginx is expecting different hostnames in the request. Problem is, these hostnames end in .localhost which isn't being resolved by DNS, so the iPad doesn't know where myapp2.localhost is, and the request never reaches Nginx on the Mac.

You've already gotten around this problem somehow when testing from the Mac. Maybe you've edited the /etc/hosts file, or you have a GUI that does that? However, you can't modify the iPad hosts file without jailbreaking.

A simple workaround is to change the default website in Nginx to the webapp you want to test from the iPad - then you could use the machinename.local address from the iPad. But you have to change this every time you want to test a different webapp.

More complicated workarounds would be to a) configure Apache on the Mac as a proxy server, and configure the iPad browser to use that as its proxy; b) set up a DNS server on your local network; c) use instead the iPad simulator on the Mac, while modifying the /etc/hosts file; or d) jailbreak the iPad and modify /etc/hosts.

  • 1
    Using iPad with Proxy Server: stackoverflow.com/questions/6917107/… – wrk2bike Dec 4 '12 at 20:11
  • i dont want to jailbreak or use emulator. i do need to easily test multiple apps. so i am left with this option as suggested by your comment. stackoverflow.com/a/11757977/80353 – Kim Stacks Dec 5 '12 at 4:15
  • however, i have a problem. i set the ipad to use proxy manual with the ip address of my macbook and the port i use 80. but i still cannot access myapp1.localhost – Kim Stacks Dec 5 '12 at 4:15
  • oh sorry i just realized that i need to turn on my charles and then set the port to 8888 – Kim Stacks Dec 5 '12 at 5:16
  • I just want to add that my personal solution is to install charles and then use charles on my macbook air. In iPad, i will turn on manual http proxy. – Kim Stacks Dec 5 '12 at 5:23

localhost is device-specific, so visiting it on your iPad is is taking you to a page on your iPad itself (that probably doesn't exist).

To access a page that is served from your Mac from your iPad, use the Mac's local IP address instead of localhost. To get your Mac's local IP, open the Network pane of System Preferences. Select your active network on the left and the IP will be shown on the right under the Connected heading. It will probably be something that looks like or

  • is there a way for me to assign a specific machine name to my macbook air and then the iPad can lookup via the machine name? – Kim Stacks Nov 25 '12 at 8:16
  • I have edited my original question a bit. I forgot to mention I have multiple webapps hosted in the webserver on my macbook air. how would this change your answer? – Kim Stacks Nov 25 '12 at 8:18
  • @kimsia Yes, you can replace the IP with computerName.local. See this answer. Multiple apps doesn't change the answer, just do what you do normally and replace localhost with the IP. So, if you normally go to http://localhost:8888/someApp/index.html, go to http://IPAddress:8888/someApp/index.html where IPAddress is the local IP. – Nathan Greenstein Nov 25 '12 at 17:25
  • i normally go to myapp1.localhost to access application1 and myapp2.localhost to access application2. so how does it work for accessing from iPad? – Kim Stacks Nov 27 '12 at 5:17
  • and also i am not sure if your suggestion is for scenario 1 or 2. or both? – Kim Stacks Nov 27 '12 at 5:18

You can try to enter your Mac's hostname followed with a .local.

So if the name of your computer is epsilon.


As stated by Nathan the ip address would work. Replace my example IP with your actual IP.

You would add your specific app information at the end of these addresses. So what ever comes after the http://localhost would be appended to the end of these URLs.

  • didn't work for me. i am not sure why. any other things I can try? – Kim Stacks Nov 27 '12 at 5:18
  • and also i am not sure if your suggestion is for scenario 1 or 2. or both? – Kim Stacks Nov 27 '12 at 5:19
  • This is work, be sure to use http then ip address – GusDeCooL Feb 26 '13 at 20:27

I think the easiest thing to do is get the hosts IP address. For example, on the command line run this :

curl icanhazip.com

You will get your external IP addres {described below as $IP_ADDRESS}.

Then on your iPad just point the browser to that IP address:

  • How to do curl in ipad? Hehehe – GusDeCooL Feb 26 '13 at 20:27
  • Turn Web Sharing on: Turn web sharing on

  • Put your website inside ~/Sites

  • Access via URL as displayed above

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .