How to Redirect Port in Microsoft Windows

Posted on


This article is an article about doing a specific thing in Microsoft Windows. That thing is to redirect port from a specific port to another port. There are several purpose for redirecting port. One of the reason is to disguise the service using a default port to use another different port. Another reason is an usual reason. If it is a service running where the access to that service is through a web browser, then redirecting it port 80 will be very helpful. That is the case if the service itself is using a different port than port 80. Below is the illustration of it in the form of an image :


In order to achieve the above scenario, the following are the steps for implementing it :

1. Run the Command Line Interface or the Command Prompt in Microsoft Windows as Administrator. The following output in the command line will appear :

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.


2. After executing the above command, create a port to listen incoming request on port 80 and then redirect it to port 8080 by executing the following command :

netsh interface portproxy add v4tov4 listenaddress=IP_Address_Machine listenport=Port_For_Redirection connectaddress=IP_Address_machine connectport=Original_Port

So, using the above command pattern, the execution exist as follows with in this example, the IP Address of the server is :

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Administrator>netsh interface portproxy add v4tov4 listenaddress= listenport=80 connectaddress= connectport=8080


3. Execute the following command to create a service that listens in port 80.

C:\Users\Administrator>netstat -ano | findstr :80
  TCP               LISTENING       2392
  TCP              LISTENING       756


Another command pattern exist to check the service running for listening any incoming request to port 80 :

C:\Users\Administrator>tasklist | findstr 756
svchost.exe                    756 Services                   0     36,236 K


4. Last but not least, execute the following command to allow any incoming request to port 80 :

C:\Users\Administrator>netsh advfirewall firewall add rule name="Allow_AppServer_Port_80" protocol=TCP dir=in localip= localport=80 action=allow


5. Finally, check the status of the redirect or the proxy port running after executing all of the previous steps using the following command :

C:\Users\Administrator>netsh interface portproxy show all

Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ----------     80     8080


As it appear in the above output, the result is very clear. There is a port listening on port 80 in a machine with the IP Address of Any incoming request to that port will be redirected to the same machine but on a different port. That port is on port 8080.

Leave a Reply