Knowledgebase

Change the Windows RDP Port Without Restarting the Server

In this guide, we’ll show you how to change the Remote Desktop (RDP) port via PowerShell on Windows (e.g. a Windows Server), adjust the Windows Firewall accordingly, and restart the Remote Desktop service.

To begin, open Windows PowerShell as Administrator (right‑click “Windows PowerShell” in the Start menu → “Run as administrator”) and paste the following script:

# Port 33445 is just an example port. You can use any free ports you want.

$newPort = 33445
$regPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
Set-ItemProperty -Path $regPath -Name 'PortNumber' -Value $newPort
if (-not (Get-NetFirewallRule -DisplayName "RDP Port $newPort" -ErrorAction SilentlyContinue)) {
    New-NetFirewallRule `
      -DisplayName "RDP Port $newPort" `
      -Direction Inbound `
      -Protocol TCP `
      -LocalPort $newPort `
      -Action Allow
}
Restart-Service -Name TermService -Force
Write-Host "The RDP port has been changed."

What this does:

  1. Defines your new RDP port in the $newPort variable.

  2. Updates the Registry key at HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\PortNumber.

  3. Creates a matching Windows Firewall rule (if it doesn’t already exist) to allow inbound TCP on your chosen port.

  4. Restarts the Remote Desktop service (TermService) so the change takes effect.

After running the script, all active RDP sessions will be disconnected due to the service restart. To reconnect, open your RDP client and enter:

<Server-IP>:<New-Port>

For example:

192.168.1.100:33445

 


 

Do you have a vServer / root server and would like to have more performance? Then a look at our range of root servers couldn't hurt!

With the discount code "KernelHost-Tutorials" you also receive a 10% discount (permanent) on your tariff!

More details:

Hardware: https://www.kernelhost.com/en/hardware

Datacenter: https://www.kernelhost.com/en/datacenter

DDoS-Protection: https://www.kernelhost.com/en/ddos-protection

PrePaid: https://www.kernelhost.com/en/prepaid

Didn't the instructions help you? You can contact us here via ticket! We're here to help.

 

© KernelHost.com - Re-posting these instructions on your website is not permitted.

  • changing, rdp, port, rdp port, windows, windows server
  • 250 Users Found This Useful

Was this answer helpful?