How to Share Localhost over Wi-Fi: A Complete Guide

Every web developer sooner or later faces the need to demonstrate their work on a real mobile device or tablet. While you're building a website or web app, it's usually only accessible at 127.0.0.1 or localhost, which means access only from the current computer. This is convenient for debugging code, but completely useless when you need to check the layout on a smartphone or show the client a working prototype connected to the same wireless network.

Fortunately, modern development tools and operating systems make it easy to extend a local host to a local network. Turning your computer into a fully-fledged web server for other devices doesn't require complex hardware. All you need is for both devices to be within the same network. Wi-Fi networks, and the access parameters on the computer were configured correctly.

In this guide, we'll cover all the setup details, from changing the server's IP address to fine-tuning firewall security rules. You'll learn why the default localhost Invisible from the outside, how to find your real IP address on the network, and which ports need to be opened for a seamless connection. Follow the steps sequentially to avoid common connection errors.

Understanding LAN architecture and localhost

Before making any configuration changes, it's important to understand why external devices don't see your server by default. When you run a project on localhost, the operating system binds the listening socket to the loopback interface. This is a virtual network interface that exists only within the computer itself and does not transmit data externally, even if it is addressed to itself via an external IP address.

For a smartphone or another laptop to be able to "knock on" your door, the server application must listen not only to the local loopback, but also to all available network interfaces or the specific IP address of your network card. In network security terms, this is called address binding. 0.0.0.0This configuration tells the system: "Accept incoming connections from any device that is connected to this computer."

⚠️ Warning: By opening access to development ports, you theoretically make them visible to all devices on your Wi-Fi network. Make sure you're connected to a trusted home or office network, not a public Wi-Fi connection at a cafe where hackers may be present.

It's also worth keeping in mind that different development tools have their own ways of managing this parameter. Some servers are configured for public access by default, while others require explicit hostname specification. Understanding this difference will save you hours of troubleshooting.

📊 What technology stack do you use for local development?
Node.js / npm
Python / Django / Flask
PHP / Laravel / XAMPP
Docker containers
Other (Ruby, Go, Java)

Finding a computer's IP address on a Wi-Fi network

The first practical step is to find out your computer's actual IP address on the local network. This is the address you'll enter in the address bar of your phone's browser. 127.0.0.1 no longer works for external connections, as it always refers to the device from which the request is made. You need an address of the format 192.168.x.x or 10.x.x.x.

The method for obtaining this information depends on your operating system. On Windows, the fastest method is using the command line. You don't need third-party utilities; the built-in system tools are sufficient. Open Terminal and enter the command to display the network configuration.

ipconfig

In the list that appears, find the section corresponding to your wireless adapter (usually it contains the word Wireless or Wi-Fi). We are interested in the line IPv4 addressWrite down these numbers, you will need them later.

For macOS and Linux users, the situation is similar, but the commands are different. In the macOS terminal, use the utility ifconfig or more modern ipconfig getifaddr en0 to obtain the Wi-Fi interface address. In Linux, the most commonly used command is ip addr or ifconfigLook for an interface with a name like wlan0 or wlp2s0.

Setting up a development server for external access

Once you've received the IP address, you'll need to reconfigure the development server itself. By default, many frameworks start on localhost, ignoring external requests. You need to explicitly specify the host 0.0.0.0 at startup. This is a universal address meaning "all available interfaces."

Let's look at popular development environments. For Node.js projects using Webpack DevServer or Vite, often it is enough to add a flag --host into the launch command. In the file package.json the script might look like this:

"scripts": {

"dev": "vite --host",

"start": "react-scripts start"

}

In the case of Python and the Django framework, the server startup command must include the option to specify the address. Standard startup python manage.py runserver Listens only to localhost. For network access, change the command:

python manage.py runserver 0.0.0.0:8000

PHP users running the built-in server must also specify the address. Command php -S localhost:8000 won't work. Use:

php -S 0.0.0.0:8000

If you're using Docker, the situation requires special attention. Containers are isolated from the host machine. When forwarding ports (port mapping) make sure the application inside the container is also listening 0.0.0.0, and not localhost. IN Dockerfile or in the server config inside the container, this is often configured separately from the command docker run.

☑️ Checking server settings

Completed: 0 / 4

Windows Firewall and Antivirus Configuration

Even if the server is configured correctly, the operating system may block incoming connections for security reasons. Windows Defender Firewall, by default, blocks incoming connections to new applications unless they are added to the exception list. This is a common cause of the "cannot access the site" error.

When you first launch a server (such as Node.js or Python), Windows may display a pop-up window asking for permission. If you accidentally clicked "Cancel" or the window didn't appear, you'll need to add the rule manually. Open the firewall control panel and go to "Advanced settings."

You need to create a rule for incoming connections. Select the port your server is running on (for example, 3000, 8000 or 8080). Make sure the network profile is set to "Private", as home Wi-Fi networks are usually classified this way.

Rule parameter Meaning Description
Rule type For the port Open a specific port number
Protocol TCP Web traffic uses the TCP protocol.
Local port 3000 (example) Your local server port
Action Allow connection Allowing traffic through the firewall
Profile Private Applies to trusted networks only

Third-party antivirus programs (Kaspersky, ESET, Avast) may have their own built-in firewalls that override Windows settings. If standard methods don't help, temporarily disable network protection in your antivirus to test. If you can connect, the problem lies with your specific antivirus settings.

⚠️ Warning: Don't create rules for the "Public" profile unless you're confident in the network's security. This could open up development ports to anyone in a cafe or airport.

Connecting mobile devices and testing

Once the server is running and the firewall is configured, it's time to test. Make sure your smartphone or tablet is connected to the same Wi-Fi network, as well as the computer. Using a mobile internet network (4G/5G) will not allow you to see the local server, as the devices will be on different networks.

Open a browser on your mobile device (Chrome, Safari). In the address bar, enter the computer's IP address you found earlier, followed by a colon and the port. The address format is:

http://192.168.1.45:3000

Replace the numbers with your IP and port. If everything is configured correctly, you will see your website. If the page doesn't load, check again: is the server running? Is the IP correct? Is your antivirus blocking it?

For developers testing APIs or backends, it's convenient to use apps like Postman or Insomnia on your phone, or simply open links in your browser.

What to do if the IP address keeps changing?

If your router assigns new IP addresses each time it reboots, you need to configure a static IP address for your computer in the router settings (DHCP Reservation) or in the Windows/macOS network settings. Find the "Static Lease" or "Address Reservation" section in the router interface and bind the MAC address of your network card to the desired IP address.

Alternative methods and tunneling

Sometimes a direct connection via a local IP is impossible or inconvenient. For example, if you're visiting someone where access to the router settings is restricted, or if your ISP uses CGNAT, hiding your connection behind a public address. In such cases, tunneling tools can help.

Ngrok — one of the most popular tools. It creates a secure tunnel from your localhost to a public server on the internet. You receive a temporary link like https://random-name.ngrok.io, which is accessible from anywhere in the world. This is ideal for demonstrating to the client.

Another option is to use built-in browser features. For example, Chrome DevTools has a feature Port Forwarding, but it only works with a USB cable connected and debugging via a browser. For wireless access, solutions like LocalTunnel or Cloudflare Tunnel.

Also worth mentioning is the feature Remote Debugging in browsers. It allows you to run a website on your phone, but debug its console and code directly on your computer. To do this, in Chrome on your PC, go to chrome://inspect, and enable USB debugging mode on your phone (although Wi-Fi debugging requires additional ADB over Wi-Fi settings).

Frequently Asked Questions (FAQ)

Why can't the phone see the computer, even though they are on the same network?

Most often, the problem lies with the Windows network profile. If the network is marked as "Public," Windows is blocking device discovery. Switch the profile to "Private" in the Wi-Fi settings. Also, check if a third-party antivirus is blocking the connection.

Is it possible to distribute localhost via a mobile hotspot?

Yes, this is possible. Enable tethering (hotspot) on your phone and connect your computer to the phone's Wi-Fi network. This will make your phone a router. You'll need to find the computer's IP address on this new network (usually in the 192.168.43.x range) and start the server at 0.0.0.0.

Is it safe to keep ports open all the time?

No, it's not recommended. While you're working on a project and on a trusted home network, the risk is minimal. However, you should shut down the server after finishing your work. If you're using public Wi-Fi, opening ports without password or token protection could allow other network users to access your code or files.

How to find an IP address on macOS faster?

Hold down the key Option (Alt) and click the Wi-Fi icon in the top menu bar. The drop-down list will show detailed IP addressing, including the IPv4 Address you need to connect.

Why does localhost:3000 work on my PC, but 192.168.xx:3000 gives an error?

This means the server is running only on the loopback interface. It is "deaf" to all external requests, even if they come from the same physical computer but through the network interface. Restart the server with the flag --host 0.0.0.0.