Laravel
Do you want to share your local Laravel project with another device on your WiFi network? Here’s a clear step-by-step guide to make your Laravel app accessible across your local network—perfect for collaborative development or testing on different devices.
Step 1: Start Laravel Server on All Network Interfaces
By default, php artisan serve
binds to localhost
, which is only accessible from your own computer. To make it accessible to other devices:
bashphp artisan serve --host=0.0.0.0
--host=0.0.0.0
tells PHP to listen for connections on all available network interfaces, not justlocalhost
.
Step 2: Find Your Computer’s Local IP Address
Now, find the IP address of the computer running the server:
- Windows:
- Open Command Prompt and type: text
ipconfig
- Look under your WiFi adapter for something like
IPv4 Address
. Example:192.168.1.101
.
- Open Command Prompt and type: text
- Mac/Linux:
- Open Terminal and type: text
ifconfig
- Look for your active network adapter’s
inet
value.
- Open Terminal and type: text
Step 3: Open Firewall Port (If Needed)
- Windows Firewall: Allow inbound connections to port
8000
, the default Laravel serve port (unless you specify a different one). - Other OSes: Ensure no firewall or security software is blocking this port.
Step 4: Access the Laravel Project from Another Computer
On any other device connected to the same WiFi:
- Open a web browser and go to: text
http://<your-computer-ip>:8000
For example, if your computer IP is192.168.1.101
, use: texthttp://192.168.1.101:8000
Troubleshooting Tips
- Make sure both devices are on the same local network.
- Use the computer’s actual IP address, not
localhost
or127.0.0.1
. - Check your computer’s firewall settings if the page does not load.
- Try a different port if
8000
is blocked: textphp artisan serve --host=0.0.0.0 --port=8080
By following these steps, anyone on your WiFi can access your Laravel site directly in their browser! This is useful for demos, joint debugging, or testing your app across multiple devices.