<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Logifire</title>
    <description>The latest articles on DEV Community by Logifire (@logifire).</description>
    <link>https://dev.to/logifire</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F402412%2F143ce9c1-58ce-41d8-aa91-25fc62533efc.png</url>
      <title>DEV Community: Logifire</title>
      <link>https://dev.to/logifire</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/logifire"/>
    <language>en</language>
    <item>
      <title>How to Access Your WSL2 Web Apps from Mobile Devices &amp; LAN</title>
      <dc:creator>Logifire</dc:creator>
      <pubDate>Thu, 01 Oct 2026 22:10:47 +0000</pubDate>
      <link>https://dev.to/logifire/how-to-access-your-wsl2-web-apps-from-mobile-devices-lan-37lf</link>
      <guid>https://dev.to/logifire/how-to-access-your-wsl2-web-apps-from-mobile-devices-lan-37lf</guid>
      <description>&lt;p&gt;If you use &lt;strong&gt;WSL2 (Windows Subsystem for Linux)&lt;/strong&gt; for web development, you've likely hit this wall: you start a development server (Vite, Next.js, Node, Django, Docker), open &lt;code&gt;http://localhost:3000&lt;/code&gt; on your Windows host, and everything works seamlessly.&lt;/p&gt;

&lt;p&gt;Then you grab your mobile phone or another device on the same Wi-Fi network to test responsive design or mobile-specific behavior... &lt;strong&gt;Connection Refused&lt;/strong&gt; or &lt;strong&gt;Request Timed Out&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I spent hours struggling with this exact issue before discovering &lt;em&gt;why&lt;/em&gt; standard Windows Firewall solutions don't work for WSL2. Here is a clear explanation of the root cause and a simple, automated fix.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Root Cause: Why Standard Firewall Rules Fail
&lt;/h2&gt;

&lt;p&gt;WSL2 does not run as a native Windows process. It operates inside a lightweight &lt;strong&gt;Hyper-V Virtual Machine&lt;/strong&gt; behind a virtual network adapter. &lt;/p&gt;

&lt;p&gt;Because of this architecture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Classic Windows Defender Firewall rules&lt;/strong&gt; (&lt;code&gt;wf.msc&lt;/code&gt; or &lt;code&gt;New-NetFirewallRule&lt;/code&gt;) apply to the host OS, &lt;strong&gt;not&lt;/strong&gt; to traffic passing into the Hyper-V virtual network.&lt;/li&gt;
&lt;li&gt;Even if you allow port 3000 in &lt;code&gt;wf.msc&lt;/code&gt; or configure port forwarding, the &lt;strong&gt;Hyper-V Firewall isolation layer&lt;/strong&gt; blocks incoming traffic originating from your LAN.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To allow external network traffic into WSL2, Windows requires specific Hyper-V firewall rules created via &lt;code&gt;New-NetFirewallHyperVRule&lt;/code&gt; using WSL's specific &lt;code&gt;VMCreatorId&lt;/code&gt;. These rules live in a separate firewall store and &lt;strong&gt;do not show up in the classic &lt;code&gt;wf.msc&lt;/code&gt; GUI&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Solution: A Simple 1-Command Fix
&lt;/h2&gt;

&lt;p&gt;To streamline this process, I created an open-source utility script that automatically resolves the WSL Hyper-V container ID, creates persistent Hyper-V firewall rules, and manages port exposure effortlessly.&lt;/p&gt;

&lt;p&gt;📦 &lt;strong&gt;Download Ready-to-Use Package:&lt;/strong&gt; &lt;a href="https://github.com/Logifire/wsl-hyperv-firewall/releases/tag/0.1" rel="noopener noreferrer"&gt;Release 0.1 (&lt;code&gt;wsl-hyperv-firewall.zip&lt;/code&gt;)&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🔗 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/Logifire/wsl-hyperv-firewall" rel="noopener noreferrer"&gt;Logifire/wsl-hyperv-firewall&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Step-by-Step Guide: Accessing WSL2 from Mobile
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1: Bind Your Dev Server to &lt;code&gt;0.0.0.0&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;By default, most development servers only listen on &lt;code&gt;127.0.0.1&lt;/code&gt; (localhost). You must instruct your server to listen on all network interfaces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vite / Vue / Svelte:&lt;/strong&gt; &lt;code&gt;npm run dev -- --host 0.0.0.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Next.js:&lt;/strong&gt; &lt;code&gt;npm run dev -- -H 0.0.0.0 -p 3000&lt;/code&gt; (or &lt;code&gt;npx next dev -H 0.0.0.0&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python HTTP Server:&lt;/strong&gt; &lt;code&gt;python -m http.server 8000 --bind 0.0.0.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node.js / Express:&lt;/strong&gt; Ensure your app uses &lt;code&gt;app.listen(3000, '0.0.0.0')&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Step 2: Open the Port in Hyper-V Firewall
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Download &lt;a href="https://github.com/Logifire/wsl-hyperv-firewall/releases/tag/0.1" rel="noopener noreferrer"&gt;&lt;code&gt;wsl-hyperv-firewall.zip&lt;/code&gt;&lt;/a&gt; from the latest release and extract it (or clone the repository).&lt;/li&gt;
&lt;li&gt;Right-click &lt;code&gt;wsl-hyperv-firewall.bat&lt;/code&gt; and select &lt;strong&gt;Run as administrator&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can run commands directly from PowerShell/CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Syntax: .\wsl-hyperv-firewall.bat add &amp;lt;port&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;\wsl-hyperv-firewall.bat&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;5173&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Alternatively, running &lt;code&gt;wsl-hyperv-firewall.bat&lt;/code&gt; without arguments launches an interactive prompt where you can simply type &lt;code&gt;add 5173&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Find Your Windows Local IP Address
&lt;/h3&gt;

&lt;p&gt;In PowerShell or CMD on Windows, check your LAN IP address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ipconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for &lt;strong&gt;IPv4 Address&lt;/strong&gt; under your active Wi-Fi or Ethernet adapter (e.g., &lt;code&gt;192.168.1.150&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Connect from Your Mobile Device
&lt;/h3&gt;

&lt;p&gt;Ensure your mobile device is connected to the same Wi-Fi network. Open your browser on the phone and navigate to:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://192.168.1.150:5173&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your dev server running inside WSL2 will now load immediately!&lt;/p&gt;




&lt;h2&gt;
  
  
  Managing Your Rules
&lt;/h2&gt;

&lt;p&gt;You can list all active Hyper-V rules created by the script or remove them when you finish testing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List active WSL Hyper-V rules&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;\wsl-hyperv-firewall.bat&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c"&gt;# Remove rule when testing is complete&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;\wsl-hyperv-firewall.bat&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;5173&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Rules created with &lt;code&gt;New-NetFirewallHyperVRule&lt;/code&gt; are persistent across reboots, so you don't need to re-add them every time you restart your machine.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;If you are developing inside WSL2 and need mobile or cross-device network testing on your LAN, traditional firewall tweaks won't cut it. Opening ports via &lt;code&gt;New-NetFirewallHyperVRule&lt;/code&gt; is the clean, native Windows solution.&lt;/p&gt;

&lt;p&gt;Download the zip archive or check out the full source code on GitHub:&lt;br&gt;
👉 &lt;strong&gt;&lt;a href="https://github.com/Logifire/wsl-hyperv-firewall" rel="noopener noreferrer"&gt;github.com/Logifire/wsl-hyperv-firewall&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Feel free to star the repo or drop a comment if this solved your WSL2 networking headaches!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written with AI assistance.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>firewall</category>
      <category>microsoft</category>
    </item>
  </channel>
</rss>
