Access Laravel using Local IP from Another Computer

Posted on

How to Access Your Laravel + Inertia + Vite Project from Another Computer? (Step-by-Step Guide)

Introduction

So, you’ve built a Laravel + Inertia.js + Vue app that runs perfectly on your own machine (locally), but now your friend or your team wants to see it on their laptop.

You try sending them http://127.0.0.1:8000, but—oops!—it doesn’t work. Why?
Because 127.0.0.1 (also known as localhost) only exists inside your computer.

In this tutorial, I’ll show you how to make your Laravel project accessible from another computer on the same Wi-Fi or LAN network — safely and easily.
No fancy deployment, no Docker, no pain.

Why You Need This Setup

When developing with Laravel + Vite + Inertia.js, you actually have two local servers running:

ComponentPurposeDefault Port
Laravel (PHP backend)Handles routes, controllers, and APIs8000
Vite (Vue frontend + HMR)Handles live reloading and assets5173

By default, both servers listen only on your local machine (127.0.0.1).
To make them visible to others, we’ll bind them to your local IP address instead.

Step 1: Find Your Local IP Address

Open Command Prompt (or Terminal) and run:

ipconfig

Look for something like this under your active network adapter:

IPv4 Address. . . . . . . . . . : 172.16.1.134

This is your local IP — we’ll use it in the next steps.
(Your IP may look different, like 192.168.1.25.)

Step 2: Update Your .env File

Open your Laravel project and edit the .env file:

APP_URL=http://172.16.1.134:8000

This tells Laravel that your app will be served from that IP and port.
It helps generate correct URLs for assets and routes.

Step 3: Configure vite.config.js

Now, open your vite.config.js and find the server section.
Update it like this:

server: {
  host: '0.0.0.0',
  port: 5173,
  hmr: {
    host: '172.16.1.134', // your local IP address
  },
},

What does this mean?

  • host: '0.0.0.0' → allows Vite to accept connections from any device.
  • hmr.host → tells Vite’s Hot Module Reloading system which IP to use when pushing updates.

Step 4: Start the Laravel Server

Run this command in your project folder:

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

This will start Laravel and make it accessible to others on your network.

Step 5: Start the Vite Dev Server

Open a new terminal tab (keep Laravel running) and start Vite:

npm run dev

You’ll see something like:

VITE v5.0  ready in 500ms
Local: http://localhost:5173/
Network: http://172.16.1.134:5173/

That “Network” URL means other devices can reach your frontend.

Step 6: Access the App from Another Computer

Now ask your friend to open their browser and go to:

http://172.16.1.134:8000

If everything’s set up correctly, they’ll see your Laravel + Inertia + Vue app live on their device!

Common Issues, Fixes & Tips

1. Windows Firewall Blocking Connections

If your friend can’t access the site, open Windows Defender Firewall and allow PHP (php.exe) and Node.js (node.exe) to communicate through private networks.

2. Different Network

Make sure both computers are connected to the same Wi-Fi or LAN.
It won’t work across different networks without extra setup (like port forwarding or tunneling).

3. Browser Caching

If assets don’t load correctly, try refreshing with Ctrl + Shift + R to clear cache.

4. Tips

  • Don’t use this setup for production. It’s perfect for local development or quick demos, not for public deployment.
  • For public demos, try tools like ngrok or Localtunnel to create secure, temporary URLs.
  • You can also automate both commands using a script:
php artisan serve --host=0.0.0.0 --port=8000 & npm run dev

Happy coding!!!