Port 5985 (WinRM over HTTP)

Port 5985 is the default port of WinRM (Windows Remote Management) over HTTP, the service that lets you run PowerShell commands on Windows servers…

Key facts

Port
5985
Protocols
TCP
Range
Registered port, 1024-49151
IANA service name
wsman

IANA assigns ports in this range to services on request, under RFC 6335.

About port 5985

Port 5985 is the default port of WinRM (Windows Remote Management) over HTTP, the service that lets you run PowerShell commands on Windows servers remotely.

WinRM is Microsoft's implementation of the WS-Management protocol, and according to the Microsoft documentation, its default ports are 5985 for HTTP and 5986 for HTTPS. IANA registers port 5985 for the wsman service.

What port 5985 is used for

  • PowerShell Remoting: commands such as Enter-PSSession and Invoke-Command connect to the server through WinRM and run commands on it.
  • Automation: management and automation tools, for example Ansible, manage Windows servers through WinRM.
  • Event collection: according to the Microsoft documentation, Event Forwarding, which forwards event logs between servers, also relies on WinRM.

According to the Microsoft documentation, WinRM encrypts all PowerShell Remoting communication after the initial authentication, even over HTTP, except when Basic authentication is used.

Port 5985 in the firewall

According to the Microsoft documentation, on a network set to the Public profile, the default firewall rule allows WinRM connections only from the same subnet. When you manage a server remotely, allow port 5985 only from the administrators' IP addresses, for example in PowerShell as administrator:

  • New-NetFirewallRule -DisplayName "WinRM from office" -Direction Inbound -Protocol TCP -LocalPort 5985 -RemoteAddress 203.0.113.10 -Action Allow

When a Linux-based firewall protects the network the server is on, the equivalent rule is:

  • UFW: ufw allow from 203.0.113.10 to any port 5985 proto tcp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="5985" protocol="tcp" accept'

On a server outside the domain, or when the connection travels over the internet, it is better to use port 5986, which is encrypted with TLS.

Risks and security

Anyone who connects to WinRM with an administrator account can run any command on the server. By default, PowerShell Remoting allows connections only for members of the Administrators group, and a few simple settings complete the protection:

  • Restrict port 5985 to the administrators' IP addresses or to the internal network.
  • Keep Basic authentication and the AllowUnencrypted option turned off, as in the service's default settings.
  • Add only the servers you manage to the TrustedHosts list, and keep it as short as possible.
  • Use strong passwords for administrator accounts, and prefer port 5986 for servers outside the domain.

Commands to check and configure

  • Test-WSMan server.example.com

    Checks whether the WinRM service on the remote server responds on port 5985.

  • winrm enumerate winrm/config/listener

    Shows the WinRM Listeners on the server, meaning the endpoints that listen for connections, with the connection type and port of each one.

  • Enable-PSRemoting -Force

    Turns on PowerShell Remoting on the server: the WinRM service, a Listener for connections, and firewall rules (PowerShell as administrator).

  • Enter-PSSession -ComputerName server.example.com

    Opens a remote PowerShell session to the server, where every command runs on the server itself.

  • Test-NetConnection server.example.com -Port 5985

    Checks from a Windows computer whether port 5985 on the server is open and reachable.

  • New-NetFirewallRule -DisplayName "WinRM from office" -Direction Inbound -Protocol TCP -LocalPort 5985 -RemoteAddress 203.0.113.10 -Action Allow

    Allows access to port 5985 in Windows Firewall only from the specified IP address (PowerShell as administrator).

  • ufw allow from 203.0.113.10 to any port 5985 proto tcp

    Allows access to port 5985 only from the specified IP address, on a Linux-based firewall (UFW).

Port 5985 in the IANA registry

Port Protocol Service IANA registry description
5985 TCP wsman WBEM WS-Management HTTP
5985 UDP wsman WBEM WS-Management HTTP

Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)

Port 5985 FAQ

What's the difference between port 5985 and port 5986?

Both ports are used by WinRM. Port 5985 works over HTTP, and port 5986 works over HTTPS with a TLS certificate, which also verifies the server's identity. Inside a domain, port 5985 is usually used, and for connections over the internet, port 5986 is better.

Is the connection on port 5985 encrypted?

Yes. According to the Microsoft documentation, after the initial authentication WinRM encrypts all PowerShell Remoting communication, even over HTTP. Basic authentication doesn't provide encryption, so keep it turned off for HTTP connections.

How do I turn on remote management in PowerShell?

On the server, run Enable-PSRemoting -Force in PowerShell as administrator, or winrm quickconfig in CMD. Then connect from your computer with Enter-PSSession -ComputerName server.example.com. The PowerShell commands page has more useful commands.

What's the difference between WinRM and Remote Desktop?

WinRM lets you run commands and scripts on the server without a graphical interface, so it suits automation and managing several servers at once. Remote Desktop, on port 3389, shows the server's full desktop.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement