Previewing My Laravel Localhost on Mobile Devices

As a developer, I often need to check how my projects look and perform on mobile devices, especially for responsive testing. However, localhost typically works only on the same PC.

Here’s the simple process I use to preview my Laravel project on a mobile device connected to the same Wi-Fi network:


Step 1 — Find Your PC’s IP Address

For Windows:

  1. Open Command Prompt.

  2. Type:

    ipconfig
  3. Note your IPv4 Address (for example: 192.168.0.107).

For Ubuntu/Linux:

  1. Open Terminal.

  2. Type the following commands:

    nmcli dev status nmcli dev show wlp2s0
  3. Find your IP4.ADDRESS value (for example: 192.168.0.107).


Step 2 — Run Laravel Server for All Devices

  1. Navigate to your Laravel project folder.

  2. Run the command:

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

    This command allows any device on the same network to access your local server.


Step 3 — Access from Your Mobile Browser

  1. Ensure your phone and PC are connected to the same Wi-Fi network.

  2. On your mobile browser, open:

    http://192.168.0.107:8000

    You can now view your Laravel website live on your mobile device.


Bonus Tip

If the site doesn’t load, check your system’s firewall settings, it might be blocking the PHP or Laravel server.


This simple method helps ensure every client website looks perfect and functions smoothly across all devices, desktop, tablet, and mobile.

Comments

Popular posts from this blog

When failed to start MariaDB database server (Solution - Again Installation)