Usually I use the method of this post to connect my mobile devices to my local dev server but I changed flats and it doesn't seem to work anymore. I seem to be doing everything right:
run server:
php artisan serve --host 0.0.0.0
check server ip (mac):
ipconfig getifaddr en0
browse ip + port on mobile device:
https://192.168.179.125:8000
Iphone shows:
This site can't be reached
Am I missing permissions or something?
Related
Trying to access to Laravel server at localhost:8000 from android phone.
What I did:
Laptop & android phone is connected to same router.
started Laravel server at localhost at port 8000
laptop's ip for the router i.e. 192.168.0.110
from phone browser tried to visit 192.168.0.110:8000
If I visit 192.168.0.110 then the default page from php server loads. But when trying to connect to that port (8000 for this example) - shows error page saying:
This site can't be reached
In laptop's browser I can visit localhost:8000
What's wrong am I doing?
What to do to connect?
For more OS:: Linux Mint and firewall (ufw) is turned off.
Update
Couldn't solve the issue. Using ngrok instead. ngrok creates a publicly shareable url tunnelled to your localhost:port.
Type this in laravel application command line
php artisan serve --host 0.0.0.0
I encountered the same challenge when i was developing a barcode verification app. This was my solution:
I ran the following code so as to be able to use my system IP to access the laravel server
php artisan serve --host 0.0.0.0
After running the code, I was able to access my laravel server from both my browser and android app through links like:
http://192.168.0.160/barcode/public/checker
or
http://192.168.0.160:8000/checker/
Also don't forget to include this in your manifest file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
instead of
localhost:8080 use
10.0.0.2:8000
this url.
if you want to serve to the application; please follow the following procedures
Connect your phone and your computer on the same network, if you sing a wifi network, or a router or even if you serve your computer with your mobile wifi run this command
for linux
ifconfig | grep "inet " | grep -v 127.0.0.1
Result Example
inet 192.168.250.1 netmask 255.255.255.0 broadcast 0.0.0.0
inet 192.168.10.1 netmask 255.255.255.0 broadcast 192.168.10.255
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
for windows
ipconfig
Result Use the IP4 Adress is the ip of your computer
Then take the ip address of your computer the serve your project with a ip by specify the host
php artisan serve --host=<Your Computer Ip Address>
now you can take your phone an open the phone browser then access the application using the ip of the computer and the port number that was used when you run php artisan serve Example http://192.168.1.10:8000
if you don't want to specify the port number when visit the application on your phone use the following command php artisan serve --host=<Your Computer Ip> --port=80 Then when visit the application on your phone use only the ip address of your computer without the port number Example http://192.168.1.10
Reference Link
Laracast How to access laravel website in phone
In OS X Mavericks (and newer), start a PHP server from the command line:
cd to/your/directory
php -S localhost:8888
It works, but the server only available on that computer only. Is there a way to test it on other devices within the same LAN?
EDIT:
You will want to launch the server with the command
php -S 0.0.0.0:8888
This will allow you to access the server remotely (see docs http://php.net/manual/en/features.commandline.webserver.php)
After this is done there are 2 ways to view the site on your local network
http://192.168.1.2:8888 where 192.168.1.2 is the IP address of your computer which you can find in your System Preferences under Network.
http://myMac.local:8888 where myMac is your local computer name which you can find in your System Preferences under Sharing.
REMEMBER: Both of these options may require your firewall to allow incoming traffic to port 8888 (or whatever port your script is listening on), if you have that running.
Start with:
php -S 0.0.0.0:8888
otherwise you bind the server to localhost;
I have setup WAMP on my computer and have created a PHP web service which is located at this URL
http://localhost/WebService/?mode=get
I am using Android Studio and running the project on my Nexus 5 phone. Both the development computer and my phone are connected to the same wifi network.
When I try and call that URL from the application I get an error:
Caused by: java.net.ConnectException: failed to connect to /127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
In my manifest I have the internet permission.
How can I access a local web service from my attached phone for dev/debug?
Emulator uses a special ip address to access the host machine local host. Use this link
http://10.0.2.2/WebService/?mode=get
In some cases you might have to assign a port other than default.
Check your URL from your emulator or from the device... if you are not able to access it, Find the right url....
Open command prompt->type ipconfig-> Get IPV4 address.... something like 192.xx...
So your URL is "http://192.xx.xx.xx/WebService/?mode=get"
To access your local host from your android emulator Use the ip address given in ipconfig.
It might be best to use
machine_name.local
as the host name, as your server/computer could change IP address if you are using DHCP
I'm trying to create a live web server on my Windows 8.1 computer.
I am connected directly to my modem using ethernet (I do have a wireless router) but I am not connected to it on this computer (desktop).
I have XAMPP working and my website appears at http://localhost/home
However, if I put in my IP from www.whatismyip.com it does not load my web server.
What am I missing?
You need to create a Port Forwarding for Port 80 to your Computers local IP Address. There should be a Admin Panel for your Router (normally the Gateway - check out with Start - Run - cmd -> then insert "ipconfig" and check out the Gateway.
And i guess in XAMPP the Internet Access is blocked. But this is a simple Apache Server, so you need to open your httpd.conf File (Should be: “c:\xampp\apache\conf\extra\httpd-xampp.conf)
Search here for:
There should be a "Deny from all" - add a # in Front to deactivate that rule.
Restart your Xampp and it should work.
Here you find more Information about Port-Forwarding:
https://managewp.com/how-to-access-a-local-website-from-internet-with-port-forwarding
Any maybe you will also need to activate Port 80 on your Firewall (depends on your Configuration)
You need a method of telling request sent to your public ip to be forwarded to the private ip of the web server. Try logging into you device (router etc) and setting this up.
I have created a basic flash socket server in PHP, it all works fine on my local machine (both in the browser and in the flash sandbox) but as soon as I get another machine to connect to my computer's Site directory, they can't get a connection open to the server!
In flash:
mySocket.connect("localhost",9999);
In PHP
$address = '127.0.0.1';
$port = 9999;
I have tried changing the flash code to the IP of my machine but then none of the clients (including the local) can connect.
Please help!
PS. Running on a mac in the Sites dir.
I am running the socket server through
terminal (PHP 5). Am running a policy file server with perl but I don't think that is the problem
"127.0.0.1" is the address for the loopback interface. It's only available on the same machine. You need to listen on all interfaces (loopback, eth0, etc) by binding the socket to "0.0.0.0".