'Can't access localhost on other devices using php artisan serve

recently I was trying to access my laravel web app on the same wifi using another device and it works well(I copied the ipv4 into the --host). However, when I tried it on a different wifi, it doesn't work at all despite following the same steps and using the correct ipv4. May I ask why is that so and how do I fix it?



Solution 1:[1]

If you want to access it from another device you should enable it like so :

php artisan serve --host=0.0.0.0

it will allow any device in your network to access it,

and it will work with wifi and with ethernet

If you set your wifi ipv4 in the host but at the same time your are connected with ethernet it won't work

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lk77