Change RDP Port in Windows: Step-by-Step Guide
In this article
Changing the Remote Desktop (RDP) port in Windows means telling the Remote Desktop Service to listen on a different TCP port than the default 3389, then opening that port in Windows Firewall and updating your client connection. This is a common hardening step: it reduces the volume of automated scans and brute-force attempts that target 3389. You do not need third-party tools—just Registry Editor, Windows Firewall, and a restart of the Remote Desktop service. Before you start, make sure you have local administrator rights, a way to access the machine physically or through another remote tool (in case RDP stops working), and a note of the new port number you plan to use. Pick a port between 49152 and 65535 to stay out of the well-known and registered ranges; avoid 3389 and any port already used by another service.
What You'll Need
- Local administrator rights on the Windows PC you want to change.
- Access to Registry Editor (regedit) and Windows Defender Firewall with Advanced Security.
- A chosen new port number (for example, 49999). Write it down.
- A backup or restore point—optional but recommended before editing the registry.
- Physical or console access to the machine, or another remote-access method, in case you lock yourself out.
Step-by-Step
- Open Registry Editor. Press Win+R, type
regedit, and press Enter. Approve the User Account Control prompt. - Navigate to the RDP port key. Go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp. The exact path is stable across Windows versions, but folder names can differ slightly in older builds. - Find the PortNumber value. In the right pane, locate the DWORD value named
PortNumber. Double-click it. - Change the base to Decimal. In the Edit DWORD dialog, select Decimal under Base. The current value should show 3389.
- Enter your new port. Type the port number you chose (for example, 49999) and click OK. Do not use a port below 1024 or one already in use.
- Open the new port in Windows Firewall. Open Windows Defender Firewall with Advanced Security (search for it in the Start menu). Click Inbound Rules on the left, then New Rule… on the right.
- Create a port rule. Choose Port, click Next, select TCP, and enter your new port in Specific local ports. Click Next.
- Allow the connection. Choose Allow the connection, click Next, leave all profiles (Domain, Private, Public) checked unless you have a reason to limit them, then give the rule a clear name such as “RDP Custom Port 49999” and finish.
- Restart the Remote Desktop Service. Open Services (search “Services”), find Remote Desktop Services, right-click it, and choose Restart. Alternatively, restart the PC. The new port takes effect only after the service restarts.
- Test the new port locally. On the same machine, open Command Prompt and run
netstat -ano | findstr :49999(replace with your port). You should see a LISTENING entry. If not, recheck the registry value and service restart. - Connect from the client. On another PC, open Remote Desktop Connection, enter the address as
hostname:49999orIP-address:49999, and connect. If the connection fails, see Troubleshooting below. - Remove the old firewall rule (optional but recommended). In Windows Defender Firewall with Advanced Security, find the built-in “Remote Desktop” inbound rules that allow TCP 3389 and disable or delete them. This prevents the old port from remaining open.
Common Mistakes
- Forgetting the firewall. Changing the registry alone does not open the port; the connection will time out until you add the inbound rule.
- Using a port that is already taken. Check with
netstat -anobefore choosing. Common conflicts include ports used by web servers, backup software, or other remote tools. - Leaving the old 3389 rule enabled. If you do not disable the default RDP firewall rules, scanners can still reach 3389, defeating part of the purpose.
- Not restarting the service. The registry change is not read until the Remote Desktop Services service restarts.
- Choosing a port below 1024. Those are reserved for well-known services and can conflict with system components.
- Locking yourself out. If you change the port and the firewall rule is wrong, you lose RDP access. Always have a fallback before you start.
Tips
- Pick a port in the dynamic range (49152–65535) to avoid clashes with registered services.
- Document the new port somewhere you can find it without RDP—for example, a password manager note or a local text file.
- If you use a router or NAT, forward the new port to the internal IP address of the PC; otherwise the change only works on the local network.
- Consider restricting the firewall rule to specific IP addresses or ranges if you only connect from known locations.
- Changing the port is not a substitute for strong passwords, account lockout policies, and keeping Windows updated.
Troubleshooting
If you cannot connect after the change, work through these checks in order.
- Confirm the service is listening. On the target PC, run
netstat -ano | findstr :YOURPORT. If nothing appears, the registry value was not saved correctly or the service did not restart. Reopen regedit, verifyPortNumberis decimal and matches your port, then restart Remote Desktop Services again. - Check the firewall rule. In Windows Defender Firewall with Advanced Security, open Inbound Rules and confirm your custom rule is enabled, set to TCP, and lists the correct local port. Also check that the rule applies to the network profile you are using (Private or Domain).
- Test locally first. From the target PC, try connecting to
localhost:YOURPORTusing Remote Desktop Connection. If that works, the service and firewall are fine and the problem is network-related (router, NAT, or corporate firewall). - Check router or NAT port forwarding. If you connect over the internet, the router must forward the new external port to the internal IP and new port of the PC. Update the forwarding rule; the old 3389 forward will no longer work.
- Verify the client address format. Use
hostname:portorIP:portwith a colon, no spaces. In some third-party RDP clients the port goes in a separate field. - Look for Group Policy overrides. On domain-joined machines, a Group Policy setting may enforce the RDP port. Check with your administrator; local registry changes can be overwritten at next policy refresh.
- If all else fails, revert. Set
PortNumberback to 3389, restart the service, and re-enable the default RDP firewall rules. Then reapply the change carefully, testing after each step.
Frequently Asked Questions
Can I use any port number for RDP?
You can use any TCP port that is not already in use by another service. Avoid the well-known range (0–1023) and pick something in the dynamic range (49152–65535) to reduce conflicts.
Do I need to restart Windows after changing the RDP port?
No, restarting the Remote Desktop Services service is enough. A full reboot also works but is not required.
Will changing the port break existing RDP shortcuts?
Yes. Any saved .rdp file or shortcut that uses the default port will fail until you add :newport to the computer name or edit the connection settings.
Is changing the RDP port enough to secure Remote Desktop?
No. It reduces automated scanning but does not replace strong passwords, account lockout policies, multi-factor authentication where available, and keeping Windows patched.
Does this work on Windows Home?
Windows Home does not include the Remote Desktop host (the part that accepts incoming connections). You can change the client port, but the host feature is only available on Pro, Enterprise, and Education editions.
What if I forget the new port?
You can find it by checking the PortNumber value in the registry path above, or by running netstat -ano | findstr LISTENING and looking for the Remote Desktop service process.