# Port Forwarding from Linux on WSL to Windows

Here I have assumed that you know how to run a webserver in development mode on localhost like `python manage.py runserver` which runs on port 8000 by default or `npm run dev` which runs on port 3000 or 5173 etc or `php -S localhost` on port 80. I also assume you know how to run these on a different port like a custom, non-default port number.

Let's say you have on your [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) (which is Ubuntu by default, so I am assuming Ubuntu 24.04 here) running django as `python` [`manage.py`](http://manage.py) `runserver` on the default port of 8000.

Check for the IP Address on your WSL instance using `ifconfig`. Note down the IP address.

```javascript
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 112.12.14.190  netmask 255.255.240.0  broadcast 112.12.15.255
        inet6 xxx::215:xxx:xxx:6423  prefixlen 64  scopeid 0x20<link>
        ether 00:xx:xx:xx:xx:23  txqueuelen 1000  (Ethernet)
        RX packets 3120  bytes 384154 (384.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1708  bytes 155068 (155.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 20  bytes 2102 (2.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20  bytes 2102 (2.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

The IP address on this Ubuntu instance at WSL is **112.12.14.190**.

Now open PowerShell in administrator mode on your host (Windows 11 laptop) and enter

```javascript
netsh interface portproxy add v4tov4 listenport=8005 listenaddress=0.0.0.0 connectport=8000 connectaddress=112.12.14.190
```

This would listen to your WSL’s port 8000 and forward it to your Windows 11 at port 8005.

Now if you open the browser and enter http://localhost:8005 in the Address bar then you should be able to see the Django powered website running on your WSL in your Windows’ browser.

Now, if you want to stop listening to port 8005 or / and want to use port 8005 for something else, then you can de-register listening to port 8005 by :

```javascript
netsh interface portproxy delete v4tov4 listenport=8005 listenaddress=0.0.0.0
```

Though I have mentioned WSL as the the OS that is the ‘guest’ on Windows, it can be applied to other platforms like [VMWare](https://www.vmware.com/) or [VirtualBox](https://www.virtualbox.org/) but most of these tools have a GUI for port-forwarding. Hence I’ve specifically mentioned WSL which is a 100% terminal based on Windows 10/11.
