Port Forwarding to a PC With a Custom RDP Listening Port
Port forwarding to a PC with a custom RDP listening port requires four values to match: the PC’s stable LAN address, the port used by the RDP service, the Windows Firewall rule, and the router’s internal-to-external mapping. For example, the PC can listen on TCP 33901 while the router exposes TCP 45222 and forwards it to 192.168.1.50:33901.
The internal port and external port do not need to be identical. The RDP client uses the external port when connecting from the internet, while local network clients use the internal port. Test each boundary separately so a failure identifies the incorrect layer.
Port forwarding to a PC: map the connection path
Choose a stable PC address and separate internal and external ports
First, identify the PC’s IPv4 address, subnet, and default gateway. A DHCP reservation on the router is usually preferable to relying on a manually configured address because it keeps the PC at the same address while allowing the router to manage the network settings. In this example, reserve 192.168.1.50 for the PC.
Choose an internal RDP port above 1024, such as 33901. This is the port on which the PC will listen after the registry change. Choose an external port, such as 45222, for the router’s internet-facing rule. Using different values makes the mapping clear:
- Internal listener: 192.168.1.50:33901
- Router external port: TCP 45222
- Forwarding destination: 192.168.1.50, TCP 33901
- Remote client address: public-address:45222
Changing the external port alone does not change the RDP service. The PC must listen on the internal port, Windows Firewall must allow that internal port, and the router must translate the external port to it.
Account for router and upstream NAT layers
With one router, the public address normally belongs to that router’s WAN interface. With two routers, an ISP modem/router followed by a personal router creates double NAT. The upstream device must either be placed in bridge or passthrough mode, or forward TCP 45222 to the WAN address of the second router. The second router then forwards TCP 45222 to 192.168.1.50:33901.
If the router’s WAN address is private or falls within carrier-grade NAT space, inbound forwarding may not reach the network at all. In that situation, changing the RDP port or adding more rules on the local router will not solve the gateway problem. Confirm that the router has a usable public IPv4 address before troubleshooting the PC.
Change and verify the RDP listening port
Set the RDP port in Regedit
Before editing the registry, record the current port and confirm that Remote Desktop is enabled. Sign in with an administrator account, open Regedit, and go to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
In the right pane, open PortNumber. Set the value to the chosen internal port, such as 33901, and select Decimal as the base before saving. The value is a REG_DWORD. Selecting Hexadecimal accidentally can produce a different port from the one intended.
The registry change affects the PC’s internal RDP listener only. It does not change the router’s external port. Do not edit unrelated Terminal Server values, and keep a note of the original PortNumber, normally 3389, for rollback.
Restart Remote Desktop and confirm the local listener
Restart the Remote Desktop Services service after saving the registry value. The service is named TermService. This can be done through Services by restarting Remote Desktop Services, or with an elevated PowerShell session using Restart-Service -Name TermService. If the service cannot restart cleanly, reboot the PC and check the listener again.
Verify the listener locally before changing the router. In an elevated PowerShell window, run Get-NetTCPConnection -LocalPort 33901 -State Listen. A result showing the port in the Listen state confirms that a process is accepting TCP connections. The command netstat -ano | findstr :33901 provides a second check and displays the process ID.
Test the loopback boundary with Test-NetConnection 127.0.0.1 -Port 33901. The result should show TcpTestSucceeded: True. A failed local test means the problem is still on the PC: the registry value may be wrong, the service may not have restarted, Remote Desktop may be disabled, or another service may be using the selected port.
Align the firewall rule and router forwarding
Allow the internal port through Windows Firewall
Create or enable an inbound Windows Firewall rule for the new internal port. Allow TCP 33901 for the network profiles that the PC actually uses, preferably limiting the remote addresses to trusted networks where practical. If RDP’s UDP transport is required, add a corresponding UDP rule for 33901 after TCP access works; TCP is the essential first test.
An existing rule for the default RDP port may not allow the newly selected port. Create a custom inbound rule named something like RDP Custom TCP 33901, select TCP, specify local port 33901, and allow the connection. Confirm that the rule applies to the active network profile. A firewall rule for 3389 does not automatically authorize 33901.
From another device on the same LAN, test the PC’s internal address with Test-NetConnection 192.168.1.50 -Port 33901, or use an equivalent TCP test tool. A successful local loopback test but a failed LAN test usually indicates the Windows Firewall, an incorrect PC address, an inactive network adapter, or a network isolation setting.
Forward the external port to the PC’s internal address
Open the router’s port-forwarding or virtual-server page and create a rule with these values:
- Service name: Custom RDP
- Protocol: TCP
- External or WAN port: 45222
- Internal or LAN port: 33901
- Destination address: 192.168.1.50
Some routers use separate start and end fields. Enter 45222 in both external fields and 33901 in both internal fields. Other routers require the same port in a single range; check that the interface distinguishes the public port from the destination port. Save the rule and apply the configuration.
The router must forward to the reserved address, not a device name that could resolve incorrectly. Check for overlapping rules, an existing service using TCP 45222, and router management settings that reserve the same WAN port. If the router has an upstream NAT device, repeat the outer forwarding step there or remove the second NAT layer.
Test locally and across the network boundary
Use host:port syntax for local, LAN, gateway, and external tests
Windows Remote Desktop accepts a port after the host name or address in host:port form. For the example above, use 192.168.1.50:33901 from the LAN and public-address:45222 from outside the network. The same format can be entered in the Remote Desktop client’s computer field. The command-line equivalent is mstsc /v:public-address:45222.
- Local-listener test: On the PC, test 127.0.0.1:33901. A failure points to the registry, service, or listener.
- LAN test: From another device on the same network, test 192.168.1.50:33901 and then open an RDP session to that address. If the TCP test fails, inspect the firewall, address reservation, and network profile.
- Gateway test: From a network outside the LAN, test the public address on TCP 45222. This verifies the WAN-side port and the router’s forwarding path. A test from inside the LAN to the public address may fail when the router lacks NAT loopback, even if the internet path is correct.
- External RDP test: From a separate internet connection, such as a mobile hotspot, open an RDP session to public-address:45222. A successful TCP probe followed by an RDP failure usually indicates incorrect client syntax, authentication, Network Level Authentication, or an RDP policy issue rather than port forwarding.
Match failure symptoms to a rollback path
If the local listener fails, restore the original registry value, normally 3389, restart TermService, and retest 127.0.0.1:3389. If the local test succeeds but the LAN test fails, disable the custom firewall rule temporarily and recreate it with the correct TCP port and active profile. Also confirm that the PC still has the reserved address.
If LAN access succeeds but the gateway test fails, inspect the router’s WAN address, the external port, the destination address, and any upstream NAT device. A private WAN address or carrier-grade NAT indicates that the forwarding request is not reaching the local router.
To fully roll back, set PortNumber back to 3389 in Decimal, restart Remote Desktop Services, remove or disable the custom firewall rule, and delete the router mapping for TCP 45222. If the intended setup is the default port, create a new mapping from the chosen external port to 192.168.1.50:3389 and verify the listener and LAN connection before testing from outside.