Beingsk's avatar

How to access laravel website in phone

I'm using ubuntu on wsl to host website locally. How to access it on the phone

tried php artisan serve and checked in phone with IP address but it didn't work.

0 likes
12 replies
Vixo's avatar

I guess you need to serve artisan through your ipv4 adress and access that ipv4 on your phone ? Not sure though, just taking a guess.

Beingsk's avatar

already did but ended up with Failed to listen on 192.168.0.20.34:8000 (reason: Cannot assign requested address)

martbock's avatar

So various things could make this fail. Firstly, if you don't provide a specific IP address for php artisan serve, it will by default use 127.0.0.1, which makes its webserver only accessible from your local host. Try setting the --host flag to your local network IP address. Secondly, there might be a firewall blocking incoming requests to the port that you are running your webserver on. Make sure that there is an allow rule in place.

1 like
sr57's avatar

same post as the previous one, everybody tell you the same thing with different words, what don't you understand?

Vixo's avatar

I just tested php artisan serve --host=0.0.0.0:8000 and tried to access with ipv4 of my machine, it did work. Give it a shot.

3 likes
Beingsk's avatar

I'm using wsl2 so tried with both wsl and LAN IP but it didn't work. Don't know whether WSL2 supports IP forwarding

sr57's avatar

Don't know whether WSL2 supports IP forwarding

Of course, wls2 supports full Linux kernel.

fxcjahid's avatar

I have solved this using this command php artisan serve --host=192.168.0.108

Don't forget to disable Microsoft Defender Firewall ( Private Network)

1 like

Please or to participate in this conversation.