# winrm Unable to connect to windows10 desktop

**URL:** <https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 22, 2016, 4:59pm UTC](https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347 "2016-08-22T16:59:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deep18](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@Deep18](https://forum.ansible.com/u/Deep18)\
**Post date:** [August 22, 2016, 4:59pm UTC](https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347/1 "2016-08-22T16:59:04Z")

</div>

Hi,

I am trying to use ansible to controla windows 10 desktop VM in my lab and cannot seem to get past the connection error.Appreciate your help here.

Here is my setup:

MacBook is the control host and trying to connect to a windows10 desktop VM. I went through and followed all instructions in the ansible doc to enable remotePowershell on windows VM, turned OFF firewall on the windows VM.The windows VM is not part of any domain.

My inventory file:

[windows]

10.203.189.4

[windows:vars] #group variables and values as a string

ansible\_connection=winrm

ansible\_user= voiceqa

ansible\_password = abcdef

ansible\_port=5986

ansible\_winrm\_server\_cert\_validation= ignore

I get the following error:

$ ansible windows --inventory-file=./hosts -m win\_ping -vvvvv

No config file found; using defaults

Loaded callback minimal of type stdout, v2.0

\<10.203.189.4\> ESTABLISH WINRM CONNECTION FOR USER: voiceqa on PORT 5986 TO 10.203.189.4

\<10.203.189.4\> WINRM CONNECT: transport=ssl endpoint=[https://10.203.189.4:5986/wsman](https://10.203.189.4:5986/wsman)

\<10.203.189.4\> WINRM CONNECTION ERROR: HTTPSConnectionPool(host=‘10.203.189.4’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘\<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10e61c8d0\>: Failed to establish a new connection: [Errno 61] Connection refused’,))

Traceback (most recent call last):

File “/Users/dnveer/venv/vqp/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py”, line 134, in \_winrm\_connect

protocol.send\_message(‘’)

File “/Users/dnveer/venv/vqp/lib/python2.7/site-packages/winrm/protocol.py”, line 207, in send\_message

return self.transport.send\_message(message)

File “/Users/dnveer/venv/vqp/lib/python2.7/site-packages/winrm/transport.py”, line 173, in send\_message

response = self.session.send(prepared\_request, timeout=self.read\_timeout\_sec)

File “/Users/dnveer/venv/vqp/lib/python2.7/site-packages/requests/sessions.py”, line 585, in send

r = adapter.send(request, \*\*kwargs)

File “/Users/dnveer/venv/vqp/lib/python2.7/site-packages/requests/adapters.py”, line 467, in send

raise ConnectionError(e, request=request)

ConnectionError: HTTPSConnectionPool(host=‘10.203.189.4’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘\<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10e61c8d0\>: Failed to establish a new connection: [Errno 61] Connection refused’,))

10.203.189.4 | FAILED! =\> {

“failed”: true,

“msg”: “ssl: HTTPSConnectionPool(host=‘10.203.189.4’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘\<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10e61c8d0\>: Failed to establish a new connection: [Errno 61] Connection refused’,))”

}

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 23, 2016, 6:57am UTC](https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347/2 "2016-08-23T06:57:11Z")

</div>

So … you are getting connection refused. So winrm is connecting but isn’t happy with something.  
Have a look in the event logs on the windows box to see if there is anything appearing when you attempt to connect.

Actually I think its possible that the problem is your inventory file. I suggest you remove the spaces in

ansible\_user= voiceqa

ansible\_password = abcdef

So they look like this:

ansible\_user=voiceqa

ansible\_password=abcdef

Give that a try and let us know how you get on.

Jon

---

<div class="post-metadata">

**Author:** ![Deep18](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@Deep18](https://forum.ansible.com/u/Deep18)\
**Post date:** [August 25, 2016, 5:02pm UTC](https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347/3 "2016-08-25T17:02:55Z")

</div>

I had to delete the 127.0.0.1 port from listening on the http to get the win\_ping working.

---

<div class="post-metadata">

**Author:** ![Cloudn\_Loud](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Cloudn\_Loud](https://forum.ansible.com/u/Cloudn_Loud)\
**Post date:** [August 15, 2017, 1:58pm UTC](https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347/4 "2017-08-15T13:58:10Z")

</div>

I am also getting the same issue from ansible linux server to win10 machine.

where you deleted the 127.0.0.1 port in windows server host file or linux server host file ?

Thanks,  
Sangeetha

---

<div class="post-metadata">

**Author:** ![Chris13](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@Chris13](https://forum.ansible.com/u/Chris13)\
**Post date:** [August 15, 2017, 3:26pm UTC](https://forum.ansible.com/t/winrm-unable-to-connect-to-windows10-desktop/22347/5 "2017-08-15T15:26:30Z")

</div>

He’s talking about on the Windows host. I didn’t have to do that with Windows Server 2008, but it could be he had something from a previous setup using the default port. As a best practice you should never use HTTP. Add this line to your inventory file:

ansible\_ssh\_port=5986

Then verify the port is not is use by anything on the Windows host. I’m guessing you already enabled WinRM, you can also check the listener: winrm enumerate winrm/config/listener
