Cannot connect to localhost from iPhone

1,249 views
Skip to first unread message

Jacobus Reyneke

unread,
May 10, 2012, 7:21:50 AM5/10/12
to phon...@googlegroups.com
Good day,
Since upgrading to Cordova 1.7 I have not been between my iPhone and my local server. This worked fine in the past. I can still test using the simulator, but when I run the app using Xcode on the actual phone, then it does not communicate to the server. I used to be able to access my server on localhost:8080, but I can't anymore.

Simon MacDonald

unread,
May 10, 2012, 10:29:31 AM5/10/12
to phon...@googlegroups.com
I'm surprised that it ever worked. If you try to connect to
localhost:8080 on your device it will attempt to open a connection on
port 8080 on your device. You'll need to change localhost to the IP
address or hostname of your server.

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

jcesar

unread,
May 10, 2012, 5:10:17 PM5/10/12
to phonegap
It worked on the simulator because in the simulator, localhost is your
machine with the local server and the simulator.
But when you install it into a device, localhost is the phone, and you
don't have the server in your phone.

As Simon told you, you have to use the ip of your server, if you can
connect the device to the same network you should use something like
"192.168.1.XXX" (you can see the server ip in the network preferences)

On 10 mayo, 16:29, Simon MacDonald <simon.macdon...@gmail.com> wrote:
> I'm surprised that it ever worked. If you try to connect to
> localhost:8080 on your device it will attempt to open a connection on
> port 8080 on your device. You'll need to change localhost to the IP
> address or hostname of your server.
>
> Simon Mac Donaldhttp://hi.im/simonmacdonald
Reply all
Reply to author
Forward
0 new messages