Trying to access to laravel server at localhost:8000 from android phone. What I did:
If I visit 192.168.0.110 then I can see the default page from php server. But when trying to connect to that port - shows error page saying:
This site can't be reached
In my laptop's browser I can visit localhost:8000
What's wrong I am doing? or 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.
If you are on Linux or Mac, type ifconfig at the terminal. If you are on Windows, type ipconfig at the command prompt. If you'd also like to pass the port parameter, just add --port=XX to the artisan serve command. And voila!
We can run the laravel project using "php artisan serve" command. It will use by default 8000 port to run the laravel app. But you want to run laravel project on a different port then the artisan command provides an option called "--port" and you can run the laravel app in a different 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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With