How to Keep a Local Web Server off the Internet

A development web server can be useful on one computer without being reachable by other devices. Decide which devices should have access, bind the server to an appropriate address, and check for other ways to reach the application. A firewall rule helps, but it does not replace checking the listener, container port publishing, a reverse proxy, or an existing tunnel.
Before changing a local development setup, record the server process, listening port, network interfaces, and any proxy or tunnel. If someone else depends on the service, coordinate the change so you do not interrupt their access unexpectedly.
Choose the Intended Audience
First distinguish same-device use from access by other devices on a trusted local network. For same-device use, the server should normally listen on a loopback address: 127.0.0.1 for IPv4 or ::1 for IPv6. A process bound to loopback accepts connections through that local address.
A process bound to 0.0.0.0 listens on all IPv4 interfaces, including interfaces facing the LAN or a routed network. The IPv6 wildcard address :: covers all IPv6 interfaces; whether that socket also accepts IPv4 connections depends on the application and socket settings. Inspect both address families.
If a second device truly needs access, loopback alone will not meet that requirement. Bind to the intended private interface and restrict incoming traffic to the expected network and port. A private address or a home router does not prove the service is unreachable from the internet. Port forwarding, VPN routes, or a proxy may provide access from outside the LAN. Do not broaden the listener merely because a test from the same device fails; first check whether the client is using the correct address family and port.
Bind the Server to Loopback
Look for the application setting usually called host, listen address, bind address, or interface. Set it to 127.0.0.1 when only local IPv4 clients need access. If the application also starts an IPv6 listener, configure that listener explicitly or confirm that it is absent. Restart the server and inspect the actual listening socket rather than assuming the configuration was applied.
Python provides a simple worked example: python -m http.server 8000 --bind 127.0.0.1. Without the bind option, the command starts a server on all interfaces. Run it only from a directory containing files you intend to serve. The http.server module provides basic security checks and is unsuitable for production, even when its listener is restricted.
Check active TCP listeners with ss -lnt on Linux or Get-NetTCPConnection -State Listen in Windows PowerShell. Read the local address and port in the output, whose layout differs between tools. A listener at 127.0.0.1:8000 is restricted to IPv4 loopback; 0.0.0.0:8000 listens on all local IPv4 addresses. Investigate any IPv6 wildcard listener, such as [::]:8000, too.
A successful new connection to localhost confirms access from that computer. It does not establish that alternate listeners, proxies, or tunnels are closed.
Check Firewall Rules
Review host firewall rules for the selected port and application. Remove unneeded inbound allow rules, or restrict them to the intended source and profile. Also check the firewall's default action and whether it is enabled: removing an allow rule does not itself create a block.
On a remote host, preserve your management connection and arrange a recovery path before changing firewall policy. Windows rule evaluation can give an explicit block priority over a conflicting allow, while Linux firewall behavior depends on its configured rules and order. Check effective policy rather than assuming a single rule decides access.
Restrict Container Port Publishing
With ordinary Docker bridge networking, the application listener and the host port mapping belong to different network environments. Binding the application to 127.0.0.1 inside the container normally makes it accessible only within that container, so publishing a host port will not make that listener reachable. The application must accept connections on the container's network interface for the bridge mapping to work.
On the host, -p 8080:80 publishes port 8080 on all host addresses by default. Use -p 127.0.0.1:8080:80 to restrict that published host port to IPv4 loopback. Inspect the active mapping with docker container port local-web, replacing local-web with the container's name.
Check Docker's version and routing settings as well. Releases older than 28.0.0 can allow other devices on the same network segment to reach ports published to localhost. Explicitly enabled direct routing can also provide a path to the container's own IP address independently of the host binding; other containers on the same bridge network can already reach its ports without publishing.
Check Proxies and Tunnels
A reverse proxy on the same host can accept remote requests and forward them to a loopback-bound application. An outbound tunnel can do the same without opening an inbound port on the origin server; Cloudflare Tunnel, for example, connects outward from the origin and then carries visitor traffic back over that connection. The proxy or tunnel connector must be able to reach the application; a connector on another device cannot use its own loopback address to reach your server.
Review proxy routes, tunnel processes, published hostnames, router forwarding, VPN sharing, and any temporary sharing tools. Stop or remove a route that is no longer intended. Loopback binding on the app does not undo a separate route that deliberately connects to it.
Verify from Another Device
After each change, check that the site still loads locally at its intended address. Then use a separate device on the relevant LAN to try the server computer's LAN address and port. Do not enter localhost on the second device, because that name refers to the second device itself.
If LAN access is supposed to be blocked, the test should fail while local access succeeds. If LAN access is intended, it should work only from the expected source network. A cellular connection with Wi-Fi turned off can provide an additional external check when a public path is in question, but one failed request does not prove every path or address family is closed.
Test IPv4 and IPv6 where both are available. Check direct host addresses and any known public hostname, proxy, or tunnel endpoint separately. Note the date, server version, listening sockets, firewall state, container mappings, test source, and observed result. These details identify which path you tested and make later configuration changes easier to compare.
Stop Unused Services
When the development session ends, stop the server and any temporary sharing process. Remove unneeded startup entries, container port mappings, router forwarding, and tunnel routes. Recheck listeners after a reboot or configuration change, because a service can restart with different defaults. Periodic review is especially useful on a workstation that changes networks between home, office, and public Wi-Fi.







