I'm using XAMPP and I wanted to see what the result is in my android phone locally so I did what is mentioned here and I got the result but because there is a problem in loading js, css, fonts and other public files I couldn't get what the original version is. I opened my browser in my phone and typed: 192.168.42.111 however I want to type mysite.local and get the correct result. BTW it doesn't show the page correctly in windows when I use localhost/mysite but mysite.local.
How can I connect to windows from android device just by typing mysite.local?
EDIT
I forgot to mention that I'm using my mobile network to connect to the internet and it is hot-spotted.
It's not possible to use Xampp from a hot-spot.Xampp is a local virtual server an you have to be in the same network.
If you are in the same network, then I would recommend to use the IPv4-Adress.
To get it do the following:
Press Win + R
Type cmd in the command field and click OK
Type in your cmd: ipconfig and press enter
Then you have to search a little bit after IPv4 in the cmd. If you have found it copy the adress and replace localhost (In your app you website) with it.
Related
I have a Xamarin app and localhost API. I'm trying to connect to the API from the app, but it could not be found. I edited my applicationhost.config file and I tried localhost, 10.0.2.2 and my IP address in the call, but it was not working.
So, how do I configure simple API access? (The API itself is working well)
There is simple workaround to connect Emulator & Simulator to localhost API.
Download third party software NgRok for Windows at any specific location of your PC. It just contains one executable file called ngrok.exe (you not need to install it).
Now execute your service on your preferred browser. Than follow below steps.
Open your ngrok.exe file path in command prompt
Keep your service url (take from your browser) with prefix ngrok http --host-header=rewrite and hit enter.
Now go to your browser where you have executed your service open new tab and type localhost:4040 than press enter -->Go to status there you will find your public url which you can use in your mobile application.
Note: Url structure should be like this public const string BaseUri = "https://8c56892f.ngrok.io/"; followed by / in last. Try not to append unnecessary /.
Benifits
You can debug services from one Visual Studio to another.
Your url will be active until you close command prompt.
In browser or command prompt track your requests status like Ok, Not found etc.
For more information visit this https://www.c-sharpcorner.com/article/exposing-local-web-server-to-internet-using-ngrok/
Hope it help you.
That 10.0.2.2 address is used for the Google emulators. For the Microsoft emulator you want to use 169.254.80.80. If that doesn't work then it must mean you have the firewall on and it's blocking the traffic. That can be solved by adding a new incoming rule for the program or port.
This question already has answers here:
How do I use a mobile phone to open localhost:4200?
(11 answers)
Closed 3 years ago.
I know from this question and answer on Super User Site running on localhost on desktop is unreachable on android device (PS: this question continues on the question in the link) that the command ng serve opens a bad configured webserver.
The question is how could I run my site on an Android device without deploying my site. I'll try to run the site on this url http://192.168.0.168:4200 using Angular-CLI.
try ng serve --host option as explained in this issue: https://github.com/angular/angular-cli/issues/1793 comment by intellix.
ng serve --host 0.0.0.0
Find your local IP address by following this
Navigate to <local IP adress>:4200 from any device on the same network.
NOTE: If you get CONNECTION_REFUSED just disable your firewall and you should be good to go.
otherwise, try https://ngrok.com/ to open a tunnel from your local network to your computer's localhost. Basically your computer forwards the 4200 port to an external IP and port that any device on the network can access.
First verify your machine IP Address.
On Windows, type ipconfig in Prompt (copy IPv4).
On Mac, type ifconfig |grep inet in Terminal (copy inet).
In my case this is 192.168.0.10.
Next, type ng serve --host 192.168.0.10.
Ok, your app on air for all devices on same network.
Now only http://192.168.0.10:4200/ will work, localhost not more.
When i tried using
ng serve --host local_ip_address
I was facing
Invalid header Request
This issue was solved using --disable-host-check
ng serve --host local_ip_address --disable-host-check
As an addition to all the answers above, you might need to adjust your proxy settings on your device. For my Android Phone, this was:
Settings
Wifi
Long Click your desired Network
Modify Network
Click advanced/extended Options
Set proxyHostname: localhost and proxyPort: 4200 and bypassProxyFor: hostIpAddress
I open my Angular2 App on Mobile device using Chrome Remote Device.
You just have to connect your phone to your pc and sync it with chrome.
Than do the port forwarding as described at the link above.
After connect your device, run your Angular app serve with ng serve --public-host
Now you can access your app in localhost:4200 from mobile device.
for Ubuntu people:
get the ip address writing this in the terminal:
hostname -I
you will get an ip address something like 192.168.0.0
and then you can just serve the app with:
ng serve --host ip_address
and then you can just open the browser in your mobile with:
http://ip_address:4200
I'm having trouble accessing my server (WAMP) using my real android device. I have an app that downloads the data and parsing it to my listview. In the emulator everything is working fine using "10.0.2.2" I tried 10.0.2.2:80, 10.0.2.2(without port #), (my laptop's ip) 192.168.254.103:80 and 192.168.254.103 (without port #) in my url. My WAMP is online and I even tried turning off firewall. Is there something missing?
UPDATE
I tried browsing via my phone's browser the ip address of my laptop and it says "FORBIDDEN". i tried configuring the httpd.conf of apache based on what I've researched but still can't access the server. please help.
Turn off Firewall -
Give permission to "WAMP folder" by using Folder
sharing options - Basically access to "All" for read, write
I build a worklight application. create android app and test this application with local machine , its working fine with emulator.but when i try to test this application with android tablet it through error "The Application failed connecting to the service".
I try to find application-descriptor.xml and fix localhost to 192.168.1.1:8080
my ip local machine,but it not working.In my tablet I can't to go to 192.168.1.1:8080/console/index.html
Can anybody help me regarding this issue. how can i fix this one in my worklight android application and run it on my android tablet
Some things to check:
- Are your tablet and your worklight development machine on the same wireless network? (they need to be!)
- Does your computer have a firewall on it which may need configuring to let the traffic through. As a test you could briefly disable the firewall and see if you then have access (subject to disclaimer of the risk involved in disabling the firewall). A test without disabling the firewall would be to try accessing 192.168.1.1:8080 from another desktop/laptop machine on that same subnet.
Check ip in local machine ipconfig ( field Adaptador de Ethernet )
Set this IP in field host name configuration server.
Rebuild
The other test is to check the direction in other machine, in the same network.
In a command window, run ipconfig and copy the IPv4 address. This is the IP address you need to place as the value for worklightServerRootURL in the file application-descriptor.xml.
The IP address you are usingnow does not look to me like the correct (public) IP address that you need to use. Try my above suggestion.
How about adding "192.168.181.1:8080" in application-descriptor.xml?
I would suggest the following debugging steps:
a) Go to your device browser and browse to http:
//xx.xx.xx.xx:8080/console
-> If this doesn't work, you have an obvious ip address issue. Then you have to figure out why, maybe you have a Symantec thingy that blocks any incoming traffic to your desktop - which they do. You should do an explicit allow.
b) If a) works, then you need to check in your code to make sure your app does try to connect to the server at startup. Or else the app will only try to connect when it calls adapter.
Now, go to your code. open the initOptions.js file. I typically, would set connectOnStartup to true, but also enable the onConnectionFailure so that it runs offline when there is no connection.
var wlInitOptions = {
// # Should application automatically attempt to connect to Worklight Server on application start up
// # The default value is true, we are overriding it to false here.
connectOnStartup : true,
// # The callback function to invoke in case application fails to connect to Worklight Server
onConnectionFailure: function (){wlCommonInit();},
// # Worklight server connection timeout
timeout: 2000,
};
3) Make sure you have the right URL in the application-descriptor.xml
<worklightServerRootURL>http://xx.xx.xx.xx:8080
</worklightServerRootURL>
If you are using the consumer edition (the real purchased WL), your URL would be.
<worklightServerRootURL>http://xx.xx.xx.xx:9080/worklight
</worklightServerRootURL>
(Note no space in between those URL - it's just this website putting a space there when there is a line break)
Redeploy your code to the WL server and create a new APK file. Update your device with the new APK file.
4) Do a test with the console again, you should see the console. Click on the Preview app link, it should work.
5) Now that you have updated your code on the server and the APK file. Open it up again on the device.
Do you still see the error message?
If things still not work.
6) Go to the app setting, since you have enable offline mode, it would allow you to access the App settings (it's the 4th button in Android) Go to Worklight Settings. Select Server Address -> Add the worklight URL to the Server URL. When you go back to the app, this will automatically reload the content from your WL server.
I've started android emulator app and trying to open from embeded browser locally started web-site, but local dns name (from /etc/hosts) is not resolved. Is there any option to enable local resolving?
Refer this URL. The issue is 127.0.0.1 is not the correct IP for accessing local server sites on emulator.
http://localhost:8080/MyTestPage.html // URL to use in computer browser
http://10.0.2.2:8080/MyTestPage.html // URL to use in emulator browser
However, you need to do some configuration changes as suggested in the URL.
Here's how to access a locally hosted website in the Android emulator.
Use IIS/Apache to host the application.
For some obscure reason, Android Virtual Device would not let you connect to the development server created by Visual Studio.
Once you host the application, use your IP address as the web address to connect to the local website. "localhost" just won't work with the AVD. Just go to the command prompt and type ipconfig to get your local ip address. You should be looking for IPv4 Address
Here's Android AVD connecting to Apache (XAMPP)
Here's connecting to IIS
Good Luck everyone and happy testing!!
You should specify your local ip address in browser, something like 192.168.xx.xx