# Inconsistent WinRM deployements

**URL:** <https://forum.ansible.com/t/inconsistent-winrm-deployements/7269>\
**Category:** Get Help\
**Tags:** winrm, windows, awx\
**Created:** [July 14, 2024, 1:00am UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269 "2024-07-14T01:00:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Longley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jason_longley/32/4207_2.png) [@Jason\_Longley](https://forum.ansible.com/u/Jason_Longley)\
**Post date:** [July 14, 2024, 1:00am UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/1 "2024-07-14T01:00:42Z")

</div>

Hi. I am having issues running playbooks against windows servers, with consistent results. I can execute a playbook on a server, and it will be successful. I will attempt to run the same playbook on the same server again (10-15 minutes later) and it will fail. I am having this issue on all my Windows servers, and all playbooks. I can come back later, and then the playbook execution will be successful. Sometimes a reboot helps, sometimes it doesn’t.

* * *

Error  
**task path: /runner/project/win\_reboot.yaml:6**

23

**fatal: [srv2]: UNREACHABLE! =\> {“changed”: false, “elapsed”: 0, “msg”: “plaintext: HTTPConnectionPool(host=‘srv2’, port=5985): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘\<urllib3.connection.HTTPConnection object at 0x77b5990103a0\>: Failed to establish a new connection: [Errno -2] Name or service not known’))”, “rebooted”: false, “unreachable”: true}**

* * *

- I am using local administrator credentials, and WinRM HTTP. All servers are a part of the same network/subnet.

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [July 14, 2024, 3:01am UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/2 "2024-07-14T03:01:40Z")

</div>

> [@Jason\_Longley](#):
>
> Name or service not known

“Name or service not known” error implies you probably have some intermittent DNS resolving issues. Do you have host IP address specified in the inventory?

---

<div class="post-metadata">

**Author:** ![Jason\_Longley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jason_longley/32/4207_2.png) [@Jason\_Longley](https://forum.ansible.com/u/Jason_Longley)\
**Post date:** [July 14, 2024, 7:29pm UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/3 "2024-07-14T19:29:41Z")

</div>

Thank you for the response. I am using hostnames, not IP addresses.

I just attempted 2 different servers by their IP’s, and got this error:

fatal: [192.168.1.177]: UNREACHABLE! =\> {“changed”: false, “elapsed”: 0, “msg”: “ssl: HTTPSConnectionPool(host=‘192.168.1.177’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘\<urllib3.connection.HTTPSConnection object at 0x7039b0d2f0a0\>: Failed to establish a new connection: [Errno 111] Connection refused’))”, “rebooted”: false, “unreachable”: true}  
PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
192.168.1.177 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [July 15, 2024, 1:54am UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/4 "2024-07-15T01:54:36Z")

</div>

Well, now you have a different error message - Connection refused. Either those two different servers do not have WinRM configured or some firewall is blocking you.

---

<div class="post-metadata">

**Author:** ![Jason\_Longley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jason_longley/32/4207_2.png) [@Jason\_Longley](https://forum.ansible.com/u/Jason_Longley)\
**Post date:** [July 15, 2024, 2:15am UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/5 "2024-07-15T02:15:45Z")

</div>

Yep, those are the 2 error messages I get. They will alternate between the 2 errors and then occasional successful run. I have all firewalls turned off. I am not quite sure how to troubleshoot this. Any ideas?

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/3/3fd3f06e8851c2945e9284c72c361a9db88e02b5.png)

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [July 15, 2024, 2:25am UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/6 "2024-07-15T02:25:51Z")

</div>

Both are network related. The first one is related to connectivity to DNS resolvers, the second one to the connectivity to the hosts themselves. Maybe your control node is experiencing network connectivity issues?

I’d suggest looking at the logs of your control node for any evidence of network interface failing. Configuring some monitoring like ping and port 5986 connectivity from control node to the hosts can help you get more insight into the problem. Intermittent connectivity issues can for example be caused by MTU limitations. I’m shooting in the dark here.

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [July 15, 2024, 2:19pm UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/7 "2024-07-15T14:19:57Z")

</div>

You also appear to have inconsistent connection settings on the Ansible side of things.

In your first error, `Name or Service Unknown` does imply DNS issues, but I also noticed that you are performing winrm over http connections (port 5985) using a hostname. Then in your second error, you’re getting connection _refused_ for winrm over _https_ (port 5986) using an _ipv4 address_.

The first issue may be intermittent DNS problems, but the second could be WinRM security or TLS related. Are your hosts even configured for winrm over https? That requires at least self-signed certs to provision, but then you would also need to make sure Ansible is configured to ignore untrusted certs. If your hosts are using certs signed by a root CA, then you could install the CA and point your inventory connection settings to trust that CA for winrm. Then, if Ansible _can_ trust the certs, you would need to be using the FQDN of the host instead of its IPAddress.

Which leads me back to the first error. Is `srv2` the actual hostname? This isn’t an FQDN. Windows is able to use NETBIOS to resolve neighboring hosts on their local network using short hostnames, but Linux doesn’t really do NETBIOS. These hosts would need to be found in a `search` domain to resolve a DNS entry for Linux to use short hostnames.

Edit: Forgot to mention: on the Windows side, winrm `listeners` for http and https are configured separately. So, even if you configured both http(s) services, the `listeners` may not be configured on both to allow connections from your Ansible control node.

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [July 15, 2024, 7:20pm UTC](https://forum.ansible.com/t/inconsistent-winrm-deployements/7269/8 "2024-07-15T19:20:04Z")

</div>

> [@Denney-tech](#):
>
> In your first error, `Name or Service Unknown` does imply DNS issues, but I also noticed that you are performing winrm over http connections (port 5985) using a hostname. Then in your second error, you’re getting connection _refused_ for winrm over _https_ (port 5986) using an _ipv4 address_.
> 
> The first issue may be intermittent DNS problems, but the second could be WinRM security or TLS related.

Good observation, although I doubt the second case is TLS related. Before TLS session is established, a TCP connection has to be already established. “Connection refused” implies that attempt to establish TCP connection was not successful and thus establishing TLS session was never attempted.

On the other hand, @Jason_Longley claims that each particular host sometimes work and sometimes not so one can only assume intermittent network connectivity issues.
