Ansible - Resolve "Connection refused" with Windows Host
by
Jeremy Canfield |
Updated: May 09 2023
| Ansible articles
Let's say Failed to establish a new connection: [Errno 111] Connection refused is being returned when attempting to connect to a Windows host.
~]$ ansible all -m win_ping -i win_hosts.yml
server1.example.com | FAILED! => {
"changed": false,
"msg": "basic: HTTPConnectionPool(host='server1.example.com', port=5985): Max retries exceeded with url: /wsman (Caused by NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f98e4707a10>: Failed to establish a new connection: [Errno 111] Connection refused',))",
"unreachable": true
}
Often, this is because the winrm (Windows Remote Management) service is stopped on the Windows host. On the Windows host, PowerShell can be used to determine if the winrm service is stopped or running. If stopped, check out my article The WinRM client cannot complete the operation within the time specified.
PS C:\> Get-Service WinRM
Status Name DisplayName
------ ---- -----------
Running winrm Windows Remote Management
Did you find this article helpful?
If so, consider buying me a coffee over at