Fixing WinRM Error: "The WinRM client received an unknown HTTP status code from the remote WS-Management service"
Error Description
This error occurs when a local Windows Remote Management (WinRM) client attempts to connect to a remote target machine, but the remote web server or WS-Management service returns an unexpected HTTP response code (such as 403 Forbidden, 404 Not Found, or 500 Internal Server Error) instead of the standard WinRM protocol responses. This mismatch typically happens due to misconfigured WinRM listeners, port conflicts with Internet Information Services (IIS), incorrect authentication settings, proxy server interference, or SSL/TLS certificate mismatches when using HTTPS.
Step-by-Step Fixes
Step 1: Verify and Restart the WinRM Service
Ensure that the Windows Remote Management service is actively running on both the local and remote computers.
- Press
Windows Key + R, typeservices.msc, and press Enter. - Scroll down to find Windows Remote Management (WS-Management).
- Check its status. If it is not running, right-click it and select Start.
- If it is already running, right-click it and select Restart.
- Double-click the service, change the Startup type to Automatic, and click OK.
Step 2: Check for Port Conflicts (Especially with IIS)
WinRM uses default ports 5985 (HTTP) and 5986 (HTTPS). If another application (like IIS) is listening on these ports or if WinRM is accidentally bound to port 80/443, it will cause this error.
- Open PowerShell as an Administrator.
- Run the following command to see what ports WinRM is listening on:
winrm enumerate winrm/config/listener - Verify that the ports match 5985 or 5986. If you notice a conflict or need to reset the quick configuration, run:
winrm quickconfig - Press Y to accept any configuration changes.
Step 3: Configure Trusted Hosts
If you are connecting to a remote machine outside of an Active Directory domain environment (such as a workgroup), your local machine must trust the remote host.
- Open PowerShell as an Administrator on your local machine.
- Run the following command to allow connections to all hosts (or replace
*with the specific remote IP address):Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force - Restart the WinRM service to apply changes:
Restart-Service winrm
Step 4: Bypass Proxy Server Settings
Sometimes local system proxy settings route internal WinRM traffic to an external proxy server, which fails to recognize the WS-Management traffic and returns an unknown HTTP status code.
- Open Command Prompt as an Administrator.
- Check if a proxy is configured by running:
netsh winhttp show proxy - If a proxy is active and routing local traffic, reset it by running:
netsh winhttp reset proxy - Alternatively, ensure your environment variables bypass proxies for local addresses by adding the remote machine's IP to your environment's
NO PROXYlist.
Step 5: Adjust Authentication Settings
The error can trigger if the client and server do not agree on the authentication method (e.g., Negotiate, Basic, CredSSP).
- Open PowerShell as an Administrator on both the client and remote machines.
- Enable standard Negotiate authentication by running:
Set-Item WSMan:\localhost\Service\Auth\Negotiate -Value \$true Set-Item WSMan:\localhost\Client\Auth\Negotiate -Value \$true - If your connection strategy requires basic authentication, enable it explicitly:
Set-Item WSMan:\localhost\Service\Auth\Basic -Value \$true Set-Item WSMan:\localhost\Client\Auth\Basic -Value \$true
ERROR_WSMAN_INVALID_BATCH_SETTINGS_PARAMETER | ERROR_WSMAN_SERVER_DESTINATION_LOCALHOST | ERROR_WSMAN_UNSUPPORTED_HTTP_STATUS_REDIRECT | ERROR_WSMAN_HTTP_REQUEST_TOO_LARGE_STATUS | ERROR_WSMAN_HTTP_SERVICE_UNAVAILABLE_STATUS
There may be some errors. Learn Microsoft