telee
telee

Reputation: 75

How to access laravel valet project from local network?

I built a laravel project in my desktop folder and running it using valet on project-name.dev . How can I access it from local network ? My IP address is 192.168.1.5 ,I'm using a mac and I tried below code but It gives me a error in my project. Is there any different solution ?

php artisan serve --host 192.168.1.5 --port 80

Any help will be appreciated!!

Upvotes: 7

Views: 19330

Answers (3)

Kofi Mokome
Kofi Mokome

Reputation: 189

You can do that by using --host=0.0.0.0. By using 0.0.0.0, you don't need to hardcode your IP address. It will automatically point to your IP address, even if it changed at some point, maybe when you connect to a different network.

So you type

php artisan serve --host=0.0.0.0 --port=80

You can now access your app using your browser or on another computer in the same network.

http://192.168.1.5:80

Upvotes: 9

sumit
sumit

Reputation: 15464

You can follow the step below

  1. Make valet site unsecure 1st using valet unsecure sitename

  2. Run valet share

A publicly accessible URL will be inserted into your clipboard and is ready to paste directly into your browser. That's it.

Please note

valet share does not currently support sharing sites that have been secured using the valet secure command.

https://laravel.com/docs/5.6/valet#sharing-sites

enter image description here

Upvotes: 10

manud99
manud99

Reputation: 468

You forgot the equals sign in your command. It should work like this:

php artisan serve --port=80 --host=192.168.1.5

To connect any of your local network devices to your mac you can type into their browser's address bar:

192.168.1.5:80

Upvotes: 16

Related Questions