Port 5986 (WinRM over HTTPS)

Port 5986 is the default port of WinRM (Windows Remote Management) over HTTPS, which encrypts remote PowerShell management of Windows servers with TLS.

Key facts

Port
5986
Protocols
TCP
Range
Registered port, 1024-49151
IANA service name
wsmans

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

About port 5986

Port 5986 is the default port of WinRM (Windows Remote Management) over HTTPS, which encrypts remote PowerShell management of Windows servers with TLS.

According to the Microsoft documentation, the default WinRM ports are 5985 for HTTP and 5986 for HTTPS, and the command winrm quickconfig -transport:https creates an HTTPS Listener, an endpoint for encrypted connections, which needs port 5986 to be open. IANA registers port 5986 for the wsmans service.

What port 5986 is used for

  • Servers outside the domain: according to the Microsoft documentation, when Kerberos authentication isn't possible, a TLS certificate verifies the server's identity, and there is no need to add it to the TrustedHosts list.
  • Management over the internet: an encrypted connection to servers in the cloud or in other branches.
  • Automation: automation tools connect to Windows servers over HTTPS, with verification of the server's certificate.

Port 5986 in the firewall

Allow port 5986 only from the IP addresses of the administrators and the automation systems, for example in PowerShell as administrator:

  • New-NetFirewallRule -DisplayName "WinRM HTTPS from office" -Direction Inbound -Protocol TCP -LocalPort 5986 -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 5986 proto tcp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="5986" protocol="tcp" accept'

When all connections go over HTTPS, you can keep port 5985 open only to the internal network, or close it completely.

Risks and security

The connection on port 5986 is encrypted with TLS and verifies the server's identity, which makes it the recommended way to manage a Windows server over the internet. A few settings keep the connection secure:

  • Use a certificate whose name matches the server name, issued by a certificate authority (CA) that your computer trusts.
  • Don't bypass certificate errors with the SkipCACheck and SkipCNCheck options of New-PSSessionOption. Fix the certificate instead.
  • Restrict port 5986 to the administrators' IP addresses.
  • Use strong passwords for administrator accounts, and renew the certificate before it expires.

Commands to check and configure

  • winrm quickconfig -transport:https

    Creates a WinRM HTTPS Listener on port 5986 on the server. Before that, install a certificate on the server whose name matches the server name.

  • winrm enumerate winrm/config/listener

    Shows the WinRM Listeners on the server, so you can confirm there is an HTTPS Listener on port 5986.

  • Test-WSMan server.example.com -UseSSL

    Checks whether WinRM on the remote server responds over HTTPS on port 5986.

  • Enter-PSSession -ComputerName server.example.com -UseSSL

    Opens a remote PowerShell session to the server, encrypted with TLS.

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

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

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

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

  • openssl s_client -connect server.example.com:5986 -servername server.example.com

    Connects to port 5986 and shows the certificate the server presents, including the name and the expiry date.

Port 5986 in the IANA registry

Port Protocol Service IANA registry description
5986 TCP wsmans WBEM WS-Management HTTP over TLS/SSL
5986 UDP wsmans WBEM WS-Management HTTP over TLS/SSL

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

Port 5986 FAQ

When should I use port 5986 instead of port 5985?

Use port 5986 when the server isn't a domain member, when you connect to it over the internet, or when you want to make sure you are connecting to the right server. Inside a domain, port 5985 with Kerberos authentication is usually enough.

Why does the connection on port 5986 fail with a certificate error?

In most cases, the name on the certificate doesn't match the name you connected with, for example when you connect by IP address, or your computer doesn't trust the issuer of the certificate. The SSL errors page explains the common certificate errors.

How do I connect to a Windows server over HTTPS in PowerShell?

Add the -UseSSL option, for example Enter-PSSession -ComputerName server.example.com -UseSSL. The connection goes over port 5986 and is encrypted with TLS. The PowerShell commands page has more commands for remote management.

How do I create an HTTPS Listener for WinRM?

Install a certificate on the server whose name matches the server name, and run winrm quickconfig -transport:https in CMD as administrator. Then open port 5986 in the firewall, and test from your computer with Test-WSMan server.example.com -UseSSL.

Shopping cart

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

Site search

Accessibility

Text size
100%
Accessibility statement