ios access localhost from real device - php

I have a local php(Laravel) server. I can access the domain "mydomain.dev" from an simulator but it does not work when I try to access it from a real device. I have the app running with the device connected to the same wifi network but it still does not work.

Open your command prompt/terminal
Type
windows ipconfig
linux ifconfig -a or ip addr show
write your IPv4 adress
exemple (windows)
Then Run your server php artisan serve or whatever you are using (wamp/laragon or easyphp ..etc)
then go to your browser in your phone and navigate to mydomain.dev
This should work.

Please try to use IP address instead of mydomain.dev. When running on a real device, it will search dns server to look up mydomain.dev. If the dns server can't recognize this url, your device can't open it.

Related

Access Symfony's localhost:8000 on other devices in the same network

I am developing a symfony project on my local machine, I wish to test it on my mobile via IP (both machines connected to wifi network). how do I access port 8000 (symfony's default port) on my mobile phone?
I already know about accessing localhost via IP of the serving device, but I want to access the port too(8000) which I cannot fetch from my devices!
Thanks for all the help
As answered to another Question this might be solved when adding the parameter 0.0.0.0:8000 to let Symfony not only respond to local requests but also accept requests from other devices.
The call then should look something like this:
php bin/console server:run 0.0.0.0:8000
Same way you accessing it from your local machine but using it's IP address e.g.:
http://192.168.1.2:8000
where 192.168.1.2 is your machine IP address in local network (check it using ipconfig command - on Windows or ifconfig on Linux/Mac OS X). Please make sure your firewalls (on local machine and on router) does not block this (8000) port.
UPD: By the way, as far as I remember, Symfony's default port is 8080, not 8000. Please check it carefully.

How to Connect Android App with a Local Web Sever using wifi

Android app Connectivity with Local Web Server
I want to connect my android app with local web server to access my php files and store data into web server database.
I also tried to use free hosting web site 000webhost.com but their database didn't provide me InnoDB DB engine, They have MYISAM which doesn't provide foreign key property...
please suggest me any solution for this issue...??
1、you can connect to you local web server through 127.0.0.1/yourproject/path
2、check you ip, like 192.168.0.110 etc.
3、try to access 192.168.0.110/youproject/path in your phone browser.
if you can access in you browser, that's your testing address
If using windows get your server ip by running:
ipconfig
in the Command Prompt. Then search for IPv4 that is your server ip;
If Using Linux Use:
ifconfig
in terminal. Then get inet addr field in wlan0.
Now you have ip address of server.
Use it as: http://yourserveripadress

Connecting Android device to Apache server

I have created a database and trying to access it using php. I execute these scripts from my phone. Now the issue is that when I try to perform any operation on the DB from the real device (my MOBILE PHONE) it says "unfortunately Closed" but works fine from the virtual device.
URL for real android device:
[http:// 127.0.0.1:8888 //android_connect/get_product_details.php]
URL for the virtual device:
[http:// 10.0.2.2 /android_connect/get_product_details.php]
The 127.0.0.1 is a loopback address so the android device or any other computer will not able to connect to it. Get a webserver (there's a lot freely available to test PHP scripts) , drop all the files in there and you will be able to access it.
say.. http://somefreewebhost.com/android_connect/get_product_details.php
Alternatively...
If you are using a webserver like WAMP, you will have an option called "Put Online". Go to your command prompt and type "ipconfig" and note down that IP address and you can even use that (provided if you are not behind any firewall)

Android ip to connect to PC

I'm confused..
I'm using XAMPP in my PC to create a local server that has a few php scripts that connects to a mysql database (also on my local server) and receive data and then send this data to my android application..
My question is about the android app, what IP should I give in the HttpPost to connect my PC and access the php script ?
Should I use the IP of my machine followed by the :port and the path to the php file or should I use only 10.0.2.2 and the path to the file ? I pretend to test this app in my real device, not in emulator.
If your android device and local computer are on same wifi router, you can run ipconfig (windows) or ifconfig (linux) to have the IP address of your computer on the network of the router (generally wtarting with 192.168.x.x)
You should use this IP address to connect from your Android device to your computer.
Note : Be sure your ports are open on your computer to let the phone connect to your computer

Unable to access localhost using android mobile

Hello I have a problem in accessing the localhost in my android device. I can't open my localhost in my browser. I installed an application that supports httpd, php and mysql. But when I have a connection in the Internet there's no error in displaying the localhost. But if I disable it, I can't open the localhost. Is there a configuration file that I need to configure in my device? I am using ICS. I am using 127.0.0.1 as my localhost I also did 127.0.0.1:8080 but it doesn't work also.
If you're trying to access your web server over your local network, then you'll need to bind the web server to an IP address that the device can access - this is not 127.0.0.1. Assuming you're on wifi with your android, you'll want to have your web server listen to something along the lines of 192.168.1.X. If you use 0.0.0.0 it will accept on all interfaces, this should work as well. Either case, you'll need to access your web server from your device using your web server's local IP address, not localhost and not 127.0.0.1
Localhost as the url in a browser should access the server running on that device.it sounds to me maybe you are connected to a remote desktop or something. Tcp/ip utilities in particular try tracert localhoast or route. config /release maybe your touting tables are messed up,weird
The localhost refers to the device on which the code is running, in this case the emulator.
If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead 127.0.0.1. You can read more from here.
I encountered the same problem while working with my localhost too. The problem turns out to be with the antivirus that i was using. I was able to access my locahost again after turning the antivirus off. But because i cannot continue using my machine without an antivirus I just have to change the antivirus to another one. It worked for me, Hope it will for you too.

Categories