Update readmes regarding wsl2 devcontainer setup

This commit is contained in:
2025-11-30 22:07:29 +00:00
parent 5865d9dbe5
commit 3fa5bf8360
2 changed files with 20 additions and 16 deletions

View File

@@ -144,6 +144,9 @@ First get the WSL IP address by running the following command in WSL:
```sh
hostname -I
# Or from Windows Command Prompt / PowerShell:
wsl hostname -I
```
Then use the WSL IP address (in my case `172.20.39.187`) in the following command to set up permanent port forwarding.
@@ -152,8 +155,8 @@ Then use the WSL IP address (in my case `172.20.39.187`) in the following comman
# Add port forwarding rule
netsh interface portproxy add v4tov4 listenport=3000 listenaddress=127.0.0.1 connectport=3000 connectaddress=172.20.39.187
# In case you need to delete the rule later, use:
netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=127.0.0.1
# Just in case you need to delete the rule later, use:
#netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=127.0.0.1
```
You should now be able to access the React dev server via `http://localhost:3000` on Windows host, instead of having to use the WSL IP address.
@@ -165,14 +168,12 @@ In case you have trouble with your Windows Firewall blocking access to the forwa
Run the following PowerShell commands to open the necessary port (just an example, ensure that the settings fit your security requirements):
```powershell
# Open port 3000 for inbound TCP traffic on all network interfaces
New-NetFirewallRule -DisplayName "WSL React Dev Server" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3000
# Do the same but only for the WSL virtual network interface
New-NetFirewallRule -DisplayName "Allow WSL Inbound Port 3000" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3000 -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))"
# Open port 3000 for inbound TCP traffic on WSL virtual network interface
New-NetFirewallRule -DisplayName "Allow WSL Inbound Port 3000" `
-Direction Inbound -Action Allow -Protocol TCP -LocalPort 3000 `
-InterfaceAlias "vEthernet (WSL (Hyper-V firewall))"
```
Just to rule out potential firewall issues, it is always an option to temporarily disable the firewall all together.
In case the above does not resolve your issues, just to rule out potential firewall issues, it is always an option to temporarily disable the firewall all together.
> WARNING: IF YOU DO THIS, DO NOT FORGET TO RE-ENABLE THE FIREWALL AFTER TESTING!