My scenario is this I have a android app that needs to connect to my computer's localhost to access some APIs that my co-workers created. I successfully accessed my localhost through another computer's browser and my phone's browser both by the way are on the same network. The problem is that when I run my android app it can't seem to connect to my computer's localhost. I already search and read a lot of forums for answers but to no avail.
Make sure your phone network is on same network. It should use same WiFi connection and off your firewall of the system then access it by your system IP that should work.
Related
I am making an application that needs to access the server database.
But since its still in the early stage, I have to delete the database quite often which is a problem because its used for other web applications too.
So I was thinking if I could test my application against my localhost database it would make it much easier for me.
I tried a few solutions on stack overflow but they didn't work for me so here is my problem.
I have lamp setup on my system.
In my browser, I can access localhost using 127.0.0.1 but if I try the same thing on my phone's browser it shows that the connection was refused.
Both my laptop and phone are connected to the same wifi network.
Is there some permission I have to provide that I am not aware of?
your 127.0.0.1 refers to your desktop.
Find out the local ip of your desktop (example 192.168.0.2) and then use that ip on your mobile browser
You should try to access to your laptop by using its IP address.
If your laptop is running on Windows, run the command ipconfig from a Command Prompt Window and then use the ip address the command returned on your phone's browser.
This should work.
Good day.I am trying to connect my android application to xamp. Basically I have an application that uses xamp, it works on an emulator but not on the actual device.After hours of searching, I found solutions to use tethering on usb and wifi. With tethering I get the error "adb problem, unable to communicate with device..please kill add".With wifi, it does not access my localhost.I know that someone might say this is a broad question.What I am asking is, how can I make my device access my xamp localhost?
I just mentioned the above to show what I tried and could not succeed.
If your android device and the device running XAMPP, are both on the same network, you could just use the private IP address of the machine running XAMPP, but if they're not on the same network, then you are gonna need to do some port forwarding and maybe get a static IP address.
Many people ask about "How get the connect from a emulator to localhost". I am asking about a reverse issue. I created a tiny http server in android app. I know his ip address and want to connect from my chrome browser to the app. If i use my a phone it is no problem, because app use "outer" ip, but in local net wifi. When i use a emulator on a development machine and open in browser ip 10.0.2.15 then can not get access to app in emulator. I tryed any ways - loopback, forward ... all is not working.
I have a Tomcat server running on Localhost. My app can access it in the emulator using 10.0.0.2:8080. But when I connect a device it can't access the server.
I've seen some similar questions but couldn't get this working. can someone give me the steps on what to do?
we use 10.0.2.2:8081 because 127.0.0.1 is reserved for the emulator, however, when you need to try the application through a real device you need to change the URL to your PC IP
go to CMD and run ipconfig, look for IPv4 address, this IP you will use it..
add it to the URL for example: http://192.somethin.somthin.somthing:8081/the-location.php
P.S: you should set your firewall off and turn off any antivirus
The device may not be on the same network as the Tomcat server. Does your network provide VPN access? If so, try installing an Android VPN client (Junos Pulse is a good free one). Connect your device to VPN and try again.
10.0.0.2 looks like an internal address. The emulator is likely able to connect because the machine on which it is running is connected to the network. The actual device needs a direct connection as well. VPN should solve that.
Situation: on PC installed server, and available address with this site: http://localhost
And installed Connectify Hotspot to share internet via wi-fi.
Also, I have android-device from which I need visit localhost on my PC. Via wi-fi is not principal.
How I can do this? I have read a lot of instructions, but they are for AVD (through 10.0.2.2), that I could do, but not with real device.
I made it.
Disable firewall while you testing connection.
Define your wi-fi IP-address by ipconfig.
On local server you need to create folder with this IP-address and put in this folder site or something, you want to open through wi-fi on mobile.
example: 192.168.77.1/www/index.php
Restart your server. After this you will be able to access to your site in PC-browser by your wi-fi IP-address. If not - restart server another once, or something going wrong :)
Turn on mobile wi-fi and in browser try to access to wi-fi IP-address.
Profit.
localhost on the device refers to the device itself, not to your computer. Get your computers IP address (ifconfig on linux or mac systems) and use this instead of localhost.