I have an app running on my computer at 127.0.0.1:3000

I would like to access that app from an iPhone connected to the same network. I have done this before but blanking out on how I did it. Any ideas?

link|improve this question

62% accept rate
feedback

4 Answers

up vote 5 down vote accepted

First you need to determine the ip address or name of the machine you are running the webserver on. I'm assuming you are running the webserver on a mac since you tagged your post macosx athough the instructions are similar for linux machines. So, on your mac:

  • Open Terminal.app. It's under Applications->Utilities.
  • Run ifconfig in the terminal. That shows you all the network interfaces on the machine. One of them is the network your machine is actively connected to. If you mac is on a wired connection that should be en0. Make a note of the address after inet - that should be the address your machine uses.
    • Let's assume you discover it's 192.168.10.1.
  • Verify that you can connect to that address from your server with nc -v 192.168.10.1 3000.
    • You should see a message like Connection to 192.168.10.1 3000 port [tcp/http] succeeded!.
    • If that doesn't work, see below.
    • If it does work, hit ctrl-C to exit the nc session.
  • Now try to connect on your client machine.

If you are unable to connect to your application on the server's real address, that means your application isn't listening on that address. You will need to investigate how to change your application configuration to modify that behavior. Since I don't know what application you are running I can't offer any good ideas on that.

link|improve this answer
10x mate... whats the difference when talking about a windows based system with Wamp server on it... is there any difference ? – Sagive SEO Jan 9 at 21:09
feedback

Find the name of your Mac using hostname (at the Terminal prompt) and use that in your URL. E.g. http://Tonys-iMac.local:3000/

If for some reason Bonjour doesn't work in your environment, find the address of the Airport on an iMac or MacBook with

ipconfig getifaddr en1

or in general with

ipconfig getifaddr $(route -n get default|awk '/interface/ { print $2 }')

link|improve this answer
This answer has some good optimizations over mine regarding finding your hostname and ip address. – Phil Hollenback Feb 2 '11 at 4:49
feedback

127.0.0.1 is the local address every computer has for itself. You have to find out what the real IP address (or Host/Bonjour name) of the machine is. Go to System Preferences, Network and look up the IP of the machine, either for the Ethernet port if you use a cable or the Airport if you use WLAN . Then open this address together with the :3000 part in Safari on the iPhone.

link|improve this answer
Also the Sharing Preference Pane always shows a name or address by which your computer can be reached. – James Feb 4 '11 at 21:02
feedback

If the application is listening on 127.0.0.1:3000 only then you can't access it from another computer. To do so you would need to modify the configuration to Listen the IP or 0.0.0.0 (all available interfaces).Thats option one.

The second option is to use a proxy.

Third option is if you can ssh from the iphone you can also use ssh forwarding.

ssh user@host -L 3000:127.0.0.1:3000

Then on your iphone open 127.0.0.1:3000

link|improve this answer
AFAIK, you can't do ssh port forwarding on an iPhone. Not if it's not jailbroken anyway. – SvenW Feb 1 '11 at 3:42
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.