Access your Laravel app from another PC on the same network, follow these steps:
php artisan serve --host=0.0.0.0 --port=8000
-
Find the Local IP Address of Your Host PC:
- Open a terminal or command prompt on the PC hosting your Laravel app.
- Run the following command to find the local IP address:
- On Windows:
ipconfig
- On macOS or Linux:
ifconfig
- Look for the IP address in the output (it will usually be in the format
192.168.x.x
).
-
Serve Your Laravel Application:
- In the terminal or command prompt, navigate to your Laravel application’s directory.
- Serve the application using Artisan, specifying the host IP address and port:
php artisan serve --host=0.0.0.0 --port=8000
- This command makes the Laravel development server accessible from any IP address on your local network.
-
Allow Firewall Access (if necessary):
- If your host PC has a firewall, ensure that it allows traffic on the specified port (e.g., 8000).
-
Access from Another PC:
- On the other PC, open a web browser.
- Enter the URL of the Laravel app using the host PC’s IP address and the specified port:
http://<host_pc_ip>:8000
- Replace
<host_pc_ip>
with the actual IP address of the host PC.
Example
If your host PC’s IP address is 192.168.1.100
and you’re serving the app on port 8000
, the URL to access from another PC would be:
http://192.168.1.100:8000
Additional Tips
- Ensure both PCs are connected to the same local network.
- Check if any antivirus or additional firewall software might be blocking the connection.
- If you need to access the app from outside your local network, consider setting up port forwarding on your router and using a service like Ngrok.