# WinRM Connection Error

**URL:** <https://forum.ansible.com/t/winrm-connection-error/28283>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 7, 2018, 5:37pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283 "2018-08-07T17:37:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Scott\_Garcia](https://forum.ansible.com/u/Scott_Garcia)\
**Post date:** [August 7, 2018, 5:37pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/1 "2018-08-07T17:37:05Z")

</div>

Trying to ping a windows machine, and I’m running into an ambiguous error from one of the python modules. Any suggestion on how to fix this?

---

<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 7, 2018, 7:44pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/2 "2018-08-07T19:44:14Z")

</div>

That’s a new one on me, but I have a few suggestions of things you can try.

Try using a hostname instead of an ip address.

Try not running ansible from a venv (should be fine, but just peeling back a layer).

Check the event log on the target windows box (eventvwr.msc) and see if there is any evidence of a successful login from the lanadmin user.

Also, what version of windows are you targeting? If I recall Server 2008/Server 2008R2 had some issues which are only fixed when SP1 is installed or its fully up to date with windows updates.

Try a complete uninistall and reinstall of ansible.

Hope this helps

Jon

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [August 7, 2018, 8:15pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/3 "2018-08-07T20:15:48Z")

</div>

Can you give us the output of **pip list** , seems like pywinrm is receiving a None value where it is expecting a string.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![John\_Roh](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@John\_Roh](https://forum.ansible.com/u/John_Roh)\
**Post date:** [August 8, 2018, 12:44am UTC](https://forum.ansible.com/t/winrm-connection-error/28283/4 "2018-08-08T00:44:37Z")

</div>

I have the same issue that I rolled back to 2.4.1.  
I have updated the packer.py for the connection\_plugsins from github and updated win\_udpates from the github, both didn’t worked at all.  
However, 2.4.1, I was able to create ami without having the winrm timeout along with packer v1.2.3.  
Good luck.

John.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [August 8, 2018, 2:55am UTC](https://forum.ansible.com/t/winrm-connection-error/28283/5 "2018-08-08T02:55:42Z")

</div>

John Roh, this would be unrelated to the packer issues. It is already known that Packer’s connection plugin is problematic with connecting to Windows hosts due to how their architecture is set up.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![Scott\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Scott\_Garcia](https://forum.ansible.com/u/Scott_Garcia)\
**Post date:** [August 8, 2018, 2:11pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/6 "2018-08-08T14:11:28Z")

</div>

# pip list

Package Version

* * *

ansible 2.6.2

asn1crypto 0.24.0

backports.ssl-match-hostname 3.5.0.1

bcrypt 3.1.4

cached-property 1.4.3

certifi 2018.4.16

cffi 1.11.5

chardet 3.0.4

cryptography 2.3

docker 3.4.1

docker-compose 1.22.0

docker-pycreds 0.3.0

dockerpty 0.4.1

docopt 0.6.2

enum34 1.1.6

functools32 3.2.3.post2

idna 2.6

ipaddress 1.0.22

Jinja2 2.10

jsonschema 2.6.0

MarkupSafe 1.0

ntlm-auth 1.2.0

paramiko 2.4.1

pip 18.0

pyasn1 0.4.4

pycparser 2.18

PyNaCl 1.2.1

pywinrm 0.3.0

PyYAML 3.13

requests 2.18.4

requests-ntlm 1.1.0

setuptools 40.0.0

six 1.11.0

texttable 0.9.1

urllib3 1.22

websocket-client 0.48.0

wheel 0.31.1

xmltodict 0.11.0

---

<div class="post-metadata">

**Author:** ![Scott\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Scott\_Garcia](https://forum.ansible.com/u/Scott_Garcia)\
**Post date:** [August 8, 2018, 3:10pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/7 "2018-08-08T15:10:49Z")

</div>

Same error is raised regardless of hostname, even if I put an erroneous one. Event log shows an alert to an ntlm authentication but I can’t find anything as far as a successful login I’m targeting Server 2012R2. Ran a clean install and still run into the issue

---

<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 10, 2018, 3:17pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/8 "2018-08-10T15:17:26Z")

</div>

Ok a couple of other ideas…

See if the s2012r2 target firewall is blocking traffic to/from port 5985  
If I recall the configure for remoting script adds a rule for this but worth checking all the profiles.

Also worth checking for any firewalling on your ansible host as well while you are at it.

Try using pywinrm without ansible - see the code examples near the bottom of this page: [https://github.com/diyan/pywinrm](https://github.com/diyan/pywinrm)

Were you able to try without venv?

Jon

---

<div class="post-metadata">

**Author:** ![naga\_venkatesh\_naidu](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@naga\_venkatesh\_naidu](https://forum.ansible.com/u/naga_venkatesh_naidu)\
**Post date:** [September 17, 2018, 3:16pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/9 "2018-09-17T15:16:58Z")

</div>

+1  
getting the same error, didn’t get the solution yet.  
please post here if anyone resolved the following error.

pip list :

Package Version

* * *

ansible 2.6.4  
asn1crypto 0.24.0  
Babel 0.9.6  
backports.ssl-match-hostname 3.5.0.1  
certifi 2018.8.24  
cffi 1.11.5  
chardet 3.0.4  
configobj 4.7.2  
cryptography 2.3.1  
decorator 3.4.0  
enum34 1.1.6  
httplib2 0.9.2  
idna 2.7  
iniparse 0.4  
ipaddr 2.1.11  
ipaddress 1.0.22  
javapackages 1.0.0  
Jinja2 2.7.2  
jmespath 0.9.0  
kitchen 1.1.1  
libvirt-python 3.9.0  
lxml 3.2.1  
MarkupSafe 0.11  
ntlm-auth 1.2.0  
paramiko 2.1.1  
passlib 1.6.5  
perf 0.1  
pip 18.0  
ply 3.4  
pyasn1 0.1.9  
pycparser 2.18  
pycurl 7.19.0  
pygobject 3.22.0  
pygpgme 0.3  
pykerberos 1.2.1  
pyliblzma 0.5.3  
python-linux-procfs 0.4.9  
pyudev 0.15  
pywinrm 0.3.0  
pyxattr 0.5.1  
PyYAML 3.10  
requests 2.19.1  
requests-kerberos 0.12.0  
requests-ntlm 1.1.0  
schedutils 0.4  
setuptools 0.9.8  
six 1.11.0  
slip 0.4.0  
slip.dbus 0.4.0  
SSSDConfig 1.16.0  
urlgrabber 3.10  
urllib3 1.23  
virtualenv 15.1.0  
wheel 0.31.1  
xmltodict 0.11.0  
yum-metadata-parser 1.1.4

ansible 2.6.4  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /bin/ansible  
python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

ansible windows -m win\_ping -vvvv

“changed”: false,  
“msg”: “kerberos: must be string or read-only buffer, not None”,  
“unreachable”: true

---

<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:** [September 20, 2018, 1:39pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/10 "2018-09-20T13:39:04Z")

</div>

Can you run

ansible windows -m win\_ping -vvvvv

This should return the stack trace.

My guess is one of your keberos-related dependencies is out of date. Sometimes the kerberous libraries are installed with the operating system, so you may need to double check the dependencies you have installed. See [https://docs.ansible.com/ansible/2.3/intro\_windows.html#installing-python-kerberos-dependencies](https://docs.ansible.com/ansible/2.3/intro_windows.html#installing-python-kerberos-dependencies)

Jon

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [September 20, 2018, 1:44pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/11 "2018-09-20T13:44:36Z")

</div>

Try adding the following and recheck with ntlm  
ansible\_winrm\_message\_encryption: auto

---

<div class="post-metadata">

**Author:** ![naga\_venkatesh\_naidu](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@naga\_venkatesh\_naidu](https://forum.ansible.com/u/naga_venkatesh_naidu)\
**Post date:** [September 20, 2018, 6:18pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/12 "2018-09-20T18:18:08Z")

</div>

Thank you @Hawkesworth.

Yeah this might be the dependensy issue with winrm on latest ansible version.

i worked absolutely fine when i used ansible 2.4.2.1 version with pywinrm[0.2.0] with basic authentication.

But kerberos authentication is not supported in that version.

---

<div class="post-metadata">

**Author:** ![naga\_venkatesh\_naidu](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@naga\_venkatesh\_naidu](https://forum.ansible.com/u/naga_venkatesh_naidu)\
**Post date:** [September 20, 2018, 6:22pm UTC](https://forum.ansible.com/t/winrm-connection-error/28283/13 "2018-09-20T18:22:40Z")

</div>

I will try this Ankit.  
Thank you.
