How to fix "The connection to the specified remote host was refused."
This common Windows error frequently occurs when using tools like Windows Remote Management (WinRM), PowerShell Remoting, Remote Desktop (RDP), or SSH. It means the physical network path to the machine exists, but the remote host is choosing not to accept traffic on that specific port. The most frequent causes include:
- The specific service (like WinRM or RDP) is not running on the remote computer.
- The remote host is not configured to listen for requests on the default ports.
- A local or network firewall is blocking the traffic on the required communication port.
- The remote computer's IP address or hostname was mistyped in the connection command.
- WinRM listener configuration is missing or corrupted on the target machine.
Step-by-Step Easy Fixes
Follow these troubleshooting steps in order to resolve the connection refusal issue.
Step 1: Verify the Remote Service is Running
The most common cause is that the service you are trying to connect to is stopped on the remote machine. If you are using PowerShell Remoting or WinRM, you must ensure the WinRM service is active.
- Click the Start menu on the remote computer, type
services.msc, and press Enter. - Scroll down the list to find Windows Remote Management (WS-Management).
- Check the Status column. If it does not say Running, right-click the service and select Start.
- To ensure it stays active, right-click the service, select Properties, change the Startup type to Automatic, and click OK.
Step 2: Enable and Configure WinRM Quick Config
If you are attempting a PowerShell remote connection, the remote host must be explicitly configured to accept remote management requests.
- Open the Start menu on the remote machine, type
cmdorPowerShell. - Right-click on Command Prompt or Windows PowerShell and select Run as administrator.
- Type the following command and press Enter:
winrm quickconfig - If prompted to make changes and analyze the system, type
y(Yes) and press Enter to confirm. This command automatically starts the service, sets the startup type to automatic, and configures a default firewall exception.
Step 3: Check Windows Firewall Settings
Even if the service is running, the Windows Defender Firewall on the remote machine might be blocking incoming traffic on the required ports (Port 5985 for HTTP WinRM, or Port 5986 for HTTPS WinRM).
- Open the Start menu on the remote computer, type
control firewall.cpl, and press Enter. - Click on Allow an app or feature through Windows Defender Firewall in the left-hand menu.
- Click the Change settings button at the top right (administrator privileges required).
- Scroll down and locate Windows Remote Management.
- Check the boxes for both Private and Public networks to allow the traffic through.
- Click OK to save the changes.
Step 4: Verify Network Location Profile
Windows often restricts remote connections if your network profile is inadvertently set to "Public" instead of "Private".
- Click on the Network/Wi-Fi icon in your Windows system tray (bottom right corner).
- Click on Properties under your active network connection.
- Under Network profile type, change the selection from Public to Private.
- Perform this check on both the client and the remote computer to ensure smooth communication.
Step 5: Configure the TrustedHosts List (For Non-Domain Environments)
If your computers are part of a Workgroup rather than a local Active Directory Domain, the client computer will refuse to connect to a remote host unless it explicitly trusts it.
- On your local client computer, open Windows PowerShell as an Administrator.
- Run the following command to allow your computer to connect to any remote host (or replace the asterisk with the specific IP address of the remote host for better security):
Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force - Restart the WinRM service on your local computer to apply the new trust configuration by running:
Restart-Service WinRM
ERROR_WSMAN_UNSUPPORTED_HTTP_STATUS_REDIRECT | ERROR_WSMAN_HTTP_REQUEST_TOO_LARGE_STATUS | ERROR_WSMAN_HTTP_NOT_FOUND_STATUS | ERROR_WSMAN_EVENTING_MISSING_LOCALE_IN_DELIVERY | ERROR_WSMAN_QUICK_CONFIG_FIREWALL_EXCEPTIONS_DISALLOWED
There may be some errors. Learn Microsoft