Connecting to Localy hosted MAMP webserver on OS X - android

I'm running an Apache and MySQL server on my MacBook for testing purposes and pursonal usage.
But when i try to connect via my Android phone, i get 'Connection Refused'
I am not surfing to localhost, but the local IP address of my macbook.
I've disabled my firewall (even if httpd,.. mamp services are allowed), same result
Changed port number, same result
I used to run a webserver on a Windows pc and raspberry pi, never had an issue, just browse to the IP address of the hosting device.. But it looks like OS X isn't allowing it
I've searched this forum a bit, but most problems were that people are browsing to localhost or trying to access it from outside the local network, couldn't really find a solution.
Step by step what i did:
1. Started Apache & MySQL services
2. Got the IP Address via ifconfig
(0). Disabled Firewall
(0). Created a virtual host
3. Browsed to the IP on my Android

Related

How can I connect an android client to my XMPP (ejabberd) server, hosted on my local machine (Windows based OS)?

I want to test my ejabberd (xmpp) server, which I've hosted on my laptop, which is working on windows 10 based OS. I want to connect my android client to this server. So I went on to the internet, and found some solutions. But they seem don't work for me. This is what I've tried:
1.) Create a hotspot on a phone. Don't use data/wifi connection, as server is already on the machine.
2.) Connect the laptop to the hotspot.
3.) On cmd (running as admin), type 'ipconfig', after starting xmpp server (Obviously).
4.) Copy IPv4 address (External IP), and access web panel on the mobile browser through it.
So, I hurried toward my phone, and typed
http://[IPv4 Address]:[port open on the server for incoming connection/5280]/admin
But it(browser) throws 'Can't reach the webpage' error.
When I run
http://localhost:5280/admin
on my laptop, I could easily access my web portal, but It's unreachable on my android phone. What can I do now?
Well I solved this problem by accessing IPv4 of my laptop through my wifi router, and connecting to the port of my server through it. Initially, my browser (both of my laptop and my phone) weren't able to reach the server's port. But I later figured out it was problem in my .yml configuration file. Server wasn't set to listen all the IPv4 calls, instead it was listening to all IPv6. So I changed this, and it then become accessible to all devices on the same wifi. So it was my bad idea to connect it through the hotspot :P

Can't access to local server with Android

My problem is linked with this post : https://stackoverflow.com/questions/28982225/android-local-server-access-over-wifi/
I have a website hosted with MAMP on a Mac mini, connected to a D-Link router. I've got a Wifi-antenna (ubiquiti) which is connected to this router too, it creates a Wifi (offline) LAN.
When I try to connect to the Mac mini's IP, it displays the website from other devices (iPhone, Windows PC) but with Android it doesn't work.
I'd like to know how the developper in the link I refered did "use DNS by redirecting all domains to his custom domain".
Or if there is another way to work around this... Client devices which connects to the Wifi network shoudn't (I wish) have to configure manually their Android network parameters...
EDIT:
ngrok.io is not a solution :
clients may not have an 3G/LTE connection on their phones
the adress / IP should be the same every time the Mac reboot
Thanks in advance

Unable to connect to an external database [duplicate]

I try to browse localhost on my HTC Magic. I have connected my device with Eclipse via USB. When browsing http://10.0.2.2 I get "Page not available". I remember, some days ago it worked.
But on the emulator I am able to browse localhost
Any ideas?
Easier way to check is in browser of emulator type 10.0.2.2 instead of localhost.
I use my local ip for that i.e. 192.168.0.1 and it works.
to access localhost on emulator: 10.0.2.2. However this may not always work for example if you have something other than a web server such as XMPP server.
assuming that you're on the same wireless network...
find your local ip (should be something 192.168.1.x) - go to the command line and type 'ipconfig' to get this. where x is the assigned local ip of the server machine.
use your local ip for your android device to connect to your localhost.
it worked for me.
If you want to access a server running on your PC from your Android device via your wireless network, first run the command ipconfig on your PC (use run (Windows logo + R), cmd, ipconfig).
Note the IPv4 address: (it should be 192.168.0.x) for some x. Use this as the server IP address, together with the port number, e.g. 192.168.0.7:8080, in your code.
Your Android device will then access the server via your wireless network router.
I needed to see localhost on my android device as well (Samsung S3) as I was developing a Java Web-application.
By far the fastest and easiest way is to go to this link and follow instructions: https://developer.chrome.com/devtools/docs/remote-debugging
* Note: You have to use Google Chrome.*
My summary of the above link:
Connect PC with Phone over USB.
Turn on Phone's "Developer options" from Settings
Go to about:inspect URL in PC's browser
Check "Discover USB Devices" (forward Ports if you are using them in your web-application)
Copy/paste localhost required link to text field in browser and click Open.
Piece of cake
You can get a public URL for your server running on a specific port on localhost.
At my work place I could access the local server by using the local IP address of my machine in the app, as most of the other answers suggest. But at home I wasn't able to do that for some reason. After trying many answers and spending many hours, I came across https://ngrok.com. It is pretty straight forward. Just download it from within the folder do:
ngrok portnumber
( from command prompt in windows)
./ngrok portnumber
(from terminal in linux)
This will give you a public URL for your local server running on that port number on localhost. You can include in your app and debug it using that URL.
You can securely expose a local web server to the internet and capture all traffic for detailed inspection. You can share the URL with your colleague developer also who might be working remotely and can debug the App/Server interaction.
Hope this saves someone's time someday.
Combining a few of the answers above plus one other additional item solved the problem for me.
As mentioned above, turn your firewall off [add a specific rule allowing the incoming connections to the port once you've successfully connected]
Find you IP address via ipconfig as mentioned above
Verify that your webserver is binding to the ip address found above and not just 127.0.0.1. Test this locally by browsing to the ip address and port. E.g. 192.168.1.113:8888. If it's not, find a solution. E.g. https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/z4rtqkKO2hg
Now test it out on your Android device. Note that I also turned off my data connection and exclusively used a wifi connection on my Android.
Mac OSX Users
If your phone and laptop are on the same wifi:
Go to System Preferences > Network to obtain your IP address
On your mobile browser, type [your IP address]:3000 to access localhost:3000
e.g. 12.45.123.456:3000
If your localhost is not running on the default HTTP port(which is port 80), you need to specify the port in your url to something that corresponds to the port on which your localhost is running. E.g. If your localhost is running on, say port 85, Your url should be
http://10.0.2.2:85
For the mac user:
I have worked on this problem for one afternoon until I realized the Xampp I used was not the real "Xampp" It was Xampp VM which runs itself based on a Linux virtual machine. That made it not running on localhost, instead, another IP. I installed the real Xampp and run my local server on localhost and then just access it with the IP of my mac.
Hope this will help someone.
If your firewall is on, turn it off and use IPv4 to test your app in the actual device, then test your application.
I had similar issue but I could not resolve it using static ip address or changing firewall settings. I found a useful utility which can be configured in a minute.
We can host our local web server on cloud for free. On exposing it on cloud we get a different URL which we can use instead of localhost and access the webserver from anywhere.
The utility is ngrok https://ngrok.com/download
Steps:
Signup
Download
Extract the file and double click to run it, this will open a command prompt
Type "ngrok.exe http 80" without quotes to host for example XAMPP apache server which runs on port 80.
Copy the new url name generated on the cmd prompt for e.g. if it is like this "fafb42f.ngrok.io"
URL like : http://localhost/php/test.php
Should be modified like this : http://fafb42f.ngrok.io/php/test.php
Now this URL can be accessed from phone.
I use testproxy to do this.
npm install testproxy
testproxy http://10.0.2.2
You then get the url (and QR code) you can access on your mobile device. It even works with virtual machines you can't reach by just entering the IP of your dev machine.
I used ngrok but now it need registration and it also has a connections request limit. Now I'm using LocalTunnel and so far it's much better.

Can't connect to laptop webserver after tethering to android phone

Searched several threads and I'm still having issues. I've tethered my laptop to my mobile phone and I'm using the data on it. I checked the IP address assigned to my laptop and made sure I'm using it, set up the apache webserver to listen on a port (no IP specified). And I can't connect from my mobile phone to my laptop web server.
Using localhost in laptop web browser works but it won't work if I use the IP specified by the android device after I tether. Also can't connect to laptop webserver from phone's mobile browser either.
Why can't I connect to my local webserver on my laptop from my mobile phone?
I've tethered both with USB and mobile hotspot and successfully shared the internet connection, but using ipconfig from the command prompt in windows I never can connect using that IP http://:3128/ 3128 is the port I have apache listening on (because I had IIS before too). Never works.

worklight server root URL fial to connect in android device

I try to deploy a worklight application into my android device (HTC Desire), without any hope I get the following error:-
Request timeout for [ANDROID IP :8080/console/apps/services
Default options: on failure timed out for
http://ANDROIDIP:8080/console/apps/services...
Make sure the host address is available to the app (especially relevant for android and iphone apps]
I find my android IP address via whatip.com and I configure my application descriptor xml file with it.
it works with android emulator when I use the following
<worklightServerRootURL>http://10.0.2.2:8080</worklightServerRootURL>
but not with the mobile device
any advice?
worklightServerRootURL should point to the public IP address of the host machine, not to the device IP.
The device and Worklight Server must be in the same network (public Internet, wifi...).
10.0.2.2 is a special address that only works on the android emulator. On the emulator, it is routed to the host where the emulator is running. On an actual device, this address won't be routed anywhere.
As Idan said, the Worklight server must be reachable from the Android device. This usually means that either the Worklight server has an address that is reachable from the internet, or that the android device has a wifi connection to the LAN where the worklight server is running.
Assuming that you are trying to test using the test server in worklight studio, first determine your computer's IP address. If you are behind a NAT router, whatip.com returns the IP of the router, not of your computer. Use ifconfig (ipconfig on windows) at a command line to determine your computer's IP address. Your computer may have several IP addresses. It is important that you choose the ones that corresponds to the LAN where you will be connecting your Android device. If you are unsure which one this is, you may need to look at your router's configuration. Next, verify that your computer's firewall has port 8080 open. Then connect your android device via wifi to the same LAN as your computer.
To verify that your device can reach the worklight server, try opening the worklight console in the phone's browser. (http://[IP of computer]:8080/console) Once that works, you should be able to use the same IP in the worklightServerRootURL to build the app so that it will work on that device.

Categories

Resources