Skip to content

How to Test Localhost on Phone and Tablet Sizes

By Pritesh Ranoliya · Updated

To test localhost at mobile sizes, open your dev server in a mobile simulator or DevTools device mode on your computer. To see it on a real phone, start the dev server on your network address (for example with --host) and open http://<your-computer's-IP>:<port> on a phone connected to the same Wi-Fi. You don’t need to deploy first.

1. On your computer: simulator or device mode

Both work on http://localhost with nothing to configure:

  • The Mobile Simulator opens your local page in a phone or tablet frame at the device’s CSS viewport, on the same tab.
  • Chrome DevTools device mode resizes the page to a preset (Chrome docs).

This catches most layout bugs: overflow, cramped text, broken grids and fixed elements in the wrong place.

2. On a real phone: use your network address

By default most dev servers listen only on localhost, which a phone can’t reach. Make the server listen on your network instead:

Tool Command
Vite vite --host
Astro astro dev --host
Next.js next dev -H 0.0.0.0

The terminal then prints a network URL such as http://192.168.1.20:5173. Open it on a phone connected to the same Wi-Fi. If it doesn’t load, check that your computer’s firewall allows the port.

Some features need a secure context (HTTPS or localhost), for example service workers and the clipboard API. On a network address over plain HTTP they will not work; test those over a tunnel or with a local HTTPS setup.

3. On a real phone over USB

  • Android: enable USB debugging, connect the phone and open chrome://inspect on your computer. Port forwarding makes localhost:3000 on the phone reach your computer’s localhost:3000, which keeps it a secure context (Chrome remote debugging).
  • iPhone: connect it to a Mac and use Safari’s Web Inspector to debug the page you opened on the phone.

Which sizes to check

Test the edges: about 360px for small Android phones, 393px for current iPhones, 440 to 448px for the largest phones and 820px for a tablet. The screen size lists have every preset, and responsive breakpoints explains how these widths map to media queries.