<?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: scrodrig</title>
    <description>The latest articles on DEV Community by scrodrig (@scrodrig).</description>
    <link>https://dev.to/scrodrig</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F254945%2F6fb45cd7-1c37-40dd-98ea-ca1adbbb361d.png</url>
      <title>DEV Community: scrodrig</title>
      <link>https://dev.to/scrodrig</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/scrodrig"/>
    <language>en</language>
    <item>
      <title>Access your WSL2 app from another device in your network</title>
      <dc:creator>scrodrig</dc:creator>
      <pubDate>Fri, 29 Sep 2023 11:47:38 +0000</pubDate>
      <link>https://dev.to/scrodrig/access-your-wsl2-app-from-another-device-in-your-network-140p</link>
      <guid>https://dev.to/scrodrig/access-your-wsl2-app-from-another-device-in-your-network-140p</guid>
      <description>&lt;p&gt;We often find ourselves in a situation where we need to test our applications outside our comfy &lt;code&gt;localhost&lt;/code&gt; and we try to access from that device and we have an ERROR.&lt;/p&gt;

&lt;p&gt;For users like me who used WSL2, I hope this might be helpful.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In Powershell&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To check in WSL is running&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;$ wsl -l -v&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Should get an output like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  NAME      STATE           VERSION
* Ubuntu    Running         2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to get our IP address in our Windows&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;$ ipconfig | findstr /i "ipv4"&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Should get an output like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IPv4 Address. . . . . . . . . . . : 192.168.1.67
IPv4 Address. . . . . . . . . . . : 172.17.16.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to get our IP address from our Linux machine Windows&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;$ wsl hostname -I&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Should get an output like this:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Run one of these example commands commands to map our ports and make them accessible through our network:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One app&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  netsh interface portproxy add v4tov4 listenport=4010 listenaddress=0.0.0.0 connectport=4010 connectaddress=172.17.30.142
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Another app&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  netsh interface portproxy add v4tov4 listenport=4020 listenaddress=0.0.0.0 connectport=4020 connectaddress=172.17.30.142
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To confirm, please run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  netsh interface portproxy show all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Should get an output like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ----------
0.0.0.0         4020        172.17.30.142   4020
0.0.0.0         4010        172.17.30.142   4010
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this configuration, you can access to the app in any device, using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://192.168.1.67:4010/
http://192.168.1.67:4020/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The official documentation is &lt;a href="https://learn.microsoft.com/en-us/windows/wsl/networking"&gt;here&lt;/a&gt;:&lt;/p&gt;

</description>
      <category>wsl</category>
      <category>development</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
