Skip to content

This notebook belongs to

Sadat Jubayer

Senior Software Engineer at Premio

If found, please return to hello@jubayer.dev

Vol. 7Seven years of building

Started
January 2020
Everyday tools
TypeScript, Vue, React, Next.js, NestJS, React Native
Education
B.Sc. CSSE, AIUB, 2020
1 min readDev ToolNode

Open your dev server on another device

Bind your development server to the local network and open it from another device on the same Wi-Fi.

Start your dev server on the laptop and open it on your phone to check a layout. On the phone, use the laptop’s local IP address and the server’s port.

diagram

One dev server, every device on the Wi‑Fi

The laptop runs the server. Another device on the same Wi-Fi opens it using the laptop’s local IP and the server’s port.

Bind the server to a network interface

A server bound to localhost accepts connections only from the same device. Tell your dev tool to listen on a network interface. For a Vite project with a dev script that runs vite, use the host option.

npm run dev -- --host 0.0.0.0

That binds the server to all IPv4 interfaces. You can pass the laptop’s LAN IPv4 address instead if you want a narrower bind. Use a trusted local network.

Open the LAN address

Find the IPv4 address for the adapter you are using. On macOS, look under the connected network’s details, or run ipconfig getifaddr en0 if en0 is that interface. On Windows, run ipconfig. On Linux, run ip address.

If the laptop’s address is 192.168.0.100 and Vite prints port 5173, open http://192.168.0.100:5173 in the other device’s browser.

Check the firewall if the page will not load

Allow incoming connections to the dev server on your private network if your firewall blocks them. Check the port the server printed and verify both devices can communicate. Some guest Wi-Fi networks isolate clients from each other.

diagram

Before and after allowing the port through the firewall

A firewall can block the request before it reaches the dev server. Allow the dev server on the private network if needed.