6

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
  • find out my 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 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.

Shafi
  • 1,718
  • 2
  • 21
  • 42

3 Answers3

9

Type this in laravel application command line

php artisan serve --host 0.0.0.0

Pradeep
  • 9,481
  • 13
  • 27
  • 34
6

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" />
ABODE
  • 788
  • 2
  • 12
  • 12
0

instead of localhost:8080 use
10.0.0.2:8000
this url.

Omkar
  • 2,810
  • 1
  • 21
  • 38