# WinRM and Kerberos. WINRM CONNECTION ERROR: Bad HTTP response returned from server. Code 500

**URL:** <https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908>\
**Category:** Get Help\
**Tags:** winrm, venv, windows, python, ubuntu\
**Created:** [November 14, 2024, 10:16am UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908 "2024-11-14T10:16:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 10:16am UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/1 "2024-11-14T10:16:01Z")

</div>

A few months ago, I was able to set up an ansible environment in a Virtual environment on a Ubuntu 24.04 server.  
I use it mainly to manage Windows Servers through WinRM with a kerberos authentication.  
I communicate on TCP/5985 port, and everything works fine.  
Lately, I tried to reproduce the same configuration. I mean setting up an ansible environment in a venv to manage Windows Servers.  
But it became **impossible** to properly communicate with Windows Servers using WinRM and kerberos. A simple win\_ping shows the error.

On the working machine:

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

On the latest ansible environment installed:

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

If I execute the same thing in very verbose mode on both machines:

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

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/8/8f6e330d4ec2a197af1cc8d1d33f98701ae8d962.png)  
 ![image](https://us1.discourse-cdn.com/ansible/original/2X/4/4c2d9497af33410307e49e538d643038bdddbc29.png)

In text mode, the full error message:

> Citation  
> user@semaphoreui:~$ source ~/venv/ansible2.17\_python3.12/bin/activate;ansible -m win\_ping -i ~/windows\_hosts SERVER -k -vvvvvv;deactivate  
> ansible [core 2.18.0]  
> config file = None  
> configured module search path = [‘/home/user/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
> ansible python module location = /home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/ansible  
> ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections  
> executable location = /home/user/venv/ansible2.17\_python3.12/bin/ansible  
> python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/home/user/venv/ansible2.17\_python3.12/bin/python3.12)  
> jinja version = 3.1.4  
> libyaml = True  
> No config file found; using defaults  
> SSH password:  
> setting up inventory plugins  
> Loading collection ansible.builtin from  
> host\_list declined parsing /home/user/windows\_hosts as it did not pass its verify\_file() method  
> script declined parsing /home/user/windows\_hosts as it did not pass its verify\_file() method  
> auto declined parsing /home/user/windows\_hosts as it did not pass its verify\_file() method  
> Parsed /home/user/windows\_hosts inventory source with ini plugin  
> redirecting (type: modules) ansible.builtin.win\_ping to ansible.windows.win\_ping  
> Loading collection ansible.windows from /home/user/.ansible/collections/ansible\_collections/ansible/windows  
> Loading callback plugin minimal of type stdout, v2.0 from /home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/ansible/plugins/callback/minimal.py  
> Attempting to use ‘default’ callback.  
> Skipping callback ‘default’, as we already have a stdout callback.  
> Attempting to use ‘junit’ callback.  
> Attempting to use ‘minimal’ callback.  
> Skipping callback ‘minimal’, as we already have a stdout callback.  
> Attempting to use ‘oneline’ callback.  
> Skipping callback ‘oneline’, as we already have a stdout callback.  
> Attempting to use ‘tree’ callback.  
> redirecting (type: modules) ansible.builtin.win\_ping to ansible.windows.win\_ping  
> redirecting (type: modules) ansible.builtin.win\_ping to ansible.windows.win\_ping  
> Using module file /home/user/.ansible/collections/ansible\_collections/ansible/windows/plugins/modules/win\_ping.ps1  
> Pipelining is enabled.  
> \<[SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)\> ESTABLISH WINRM CONNECTION FOR USER: [THE-WINUSER@ENTERPRISE.COM](mailto:THE-WINUSER@ENTERPRISE.COM) on PORT 5985 TO [SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)  
> creating Kerberos CC at /tmp/tmpfeohiy61  
> calling kinit with subprocess for principal [THE-WINUSER@ENTERPRISE.COM](mailto:THE-WINUSER@ENTERPRISE.COM)  
> kinit succeeded for principal [THE-WINUSER@ENTERPRISE.COM](mailto:THE-WINUSER@ENTERPRISE.COM)  
> \<[SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)\> WINRM CONNECT: transport=kerberos endpoint=[http://SERVER.ENTERPRISE.COM:5985/wsman](http://SERVER.ENTERPRISE.COM:5985/wsman)  
> \<[SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)\> WINRM CONNECTION ERROR: Bad HTTP response returned from server. Code 500  
> Traceback (most recent call last):  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 268, in send\_message  
> root = ET.fromstring(ex.response\_text)  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/usr/lib/python3.12/xml/etree/ElementTree.py”, line 1336, in XML  
> return parser.close()  
> ^^^^^^^^^^^^^^  
> xml.etree.ElementTree.ParseError: no element found: line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/ansible/plugins/connection/winrm.py”, line 483, in \_winrm\_connect  
self.shell\_id = protocol.open\_shell(codepage=65001) # UTF-8  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 193, in open\_shell  
res = self.send\_message(xmltodict.unparse(req))  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 271, in send\_message  
raise ex  
File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 263, in send\_message  
resp = self.transport.send\_message(message)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/transport.py”, line 336, in send\_message  
response = self.\_send\_message\_request(session, prepared\_request)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/transport.py”, line 352, in \_send\_message\_request  
raise WinRMTransportError(“http”, ex.response.status\_code, response\_text.decode())  
winrm.exceptions.WinRMTransportError: Bad HTTP response returned from server. Code 500  
SERVER | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “kerberos: Bad HTTP response returned from server. Code 500”,  
“unreachable”: true  
}

Here is the environment details on the running machine:

> Distributor ID: Ubuntu  
> Description: Ubuntu 24.04.1 LTS  
> Release: 24.04  
> Codename: noble

> pip freeze  
> ansible-core==2.17.3  
> certifi==2024.8.30  
> cffi==1.17.0  
> charset-normalizer==3.3.2  
> cryptography==43.0.0  
> decorator==5.1.1  
> gssapi==1.8.3  
> idna==3.8  
> Jinja2==3.1.4  
> jmespath==1.0.1  
> kerberos==1.3.1  
> krb5==0.6.0  
> MarkupSafe==2.1.5  
> packaging==24.1  
> pycparser==2.22  
> pykerberos==1.2.4  
> pyspnego==0.11.1  
> pywinrm==0.5.0  
> PyYAML==6.0.2  
> requests==2.32.3  
> requests-kerberos==0.15.0  
> requests\_ntlm==1.3.0  
> resolvelib==1.0.1  
> urllib3==2.2.2  
> xmltodict==0.13.0

> Collection Version  
> ansible.posix 1.5.4  
> ansible.utils 5.1.1  
> ansible.windows 2.4.0  
> chocolatey.chocolatey 1.5.1  
> community.crypto 2.21.1  
> community.dns 3.0.2  
> community.general 9.1.0  
> community.library\_inventory\_filtering\_v1 1.0.1  
> community.mysql 3.10.3  
> community.vmware 4.5.0  
> community.windows 2.2.0  
> microsoft.ad 1.6.0  
> vmware.vmware 1.3.0

On the **non-working** machines, I’ve tried to install exactly the same pip packages’ version or the latest version. Whatever I try, I always get this:

> kerberos: Bad HTTP response returned from server. Code 500

error message.

As we can see, the WinRM connection is clearly established:

> ESTABLISH WINRM CONNECTION FOR USER: [USER@ENTERPRISE.COM](mailto:USER@ENTERPRISE.COM) on PORT 5985 TO [SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)  
> creating Kerberos CC at /tmp/tmpfeohiy61

and the kerberos authentication is OK:

> calling kinit with subprocess for principal [USER@ENTERPRISE.COM](mailto:USER@ENTERPRISE.COM)  
> kinit succeeded for principal [USER@ENTERPRISE.COM](mailto:USER@ENTERPRISE.COM)  
> \<[SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)\> WINRM CONNECT: transport=kerberos endpoint=[http://SERVER.ENTERPRISE.COM:5985/wsman](http://SERVER.ENTERPRISE.COM:5985/wsman)

And then:

> \<[SERVER.ENTERPRISE.COM](http://SERVER.ENTERPRISE.COM)\> WINRM CONNECTION ERROR: Bad HTTP response returned from server. Code 500  
> Traceback (most recent call last):  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 268, in send\_message  
> root = ET.fromstring(ex.response\_text)  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/usr/lib/python3.12/xml/etree/ElementTree.py”, line 1336, in XML  
> return parser.close()  
> ^^^^^^^^^^^^^^  
> xml.etree.ElementTree.ParseError: no element found: line 1, column 0  
> During handling of the above exception, another exception occurred:  
> Traceback (most recent call last):  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/ansible/plugins/connection/winrm.py”, line 483, in \_winrm\_connect  
> self.shell\_id = protocol.open\_shell(codepage=65001) # UTF-8  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 193, in open\_shell  
> res = self.send\_message(xmltodict.unparse(req))  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 271, in send\_message  
> raise ex  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/protocol.py”, line 263, in send\_message  
> resp = self.transport.send\_message(message)  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/transport.py”, line 336, in send\_message  
> response = self.\_send\_message\_request(session, prepared\_request)  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/home/user/venv/ansible2.17\_python3.12/lib/python3.12/site-packages/winrm/transport.py”, line 352, in \_send\_message\_request  
> raise WinRMTransportError(“http”, ex.response.status\_code, response\_text.decode())  
> winrm.exceptions.WinRMTransportError: Bad HTTP response returned from server. Code 500  
> SERVER | UNREACHABLE! =\> {  
> “changed”: false,  
> “msg”: “kerberos: Bad HTTP response returned from server. Code 500”,  
> “unreachable”: true  
> }

I’ve tried many things, and I do know how to fix this very annoying issue.

I really need you **help**.

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [November 14, 2024, 1:01pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/2 "2024-11-14T13:01:08Z")

</div>

> [@Iwan](#):
>
> Bad HTTP response returned from server. Code 500

Hi 🙂 For testing purpose, are you able to allow unencrypted connection with something like this :

```auto
Set-Item -Path WSMan:\localhost\Service\AllowUnencrypted -Value true

```

And then re-run your playbook to check if it behaves the same or not. (my idea is to check if your venv and collections may be impacted by this setting)

---

<div class="post-metadata">

**Author:** ![anon81884396](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon81884396](https://forum.ansible.com/u/anon81884396)\
**Post date:** [November 14, 2024, 1:11pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/3 "2024-11-14T13:11:26Z")

</div>

Working with Kerberos in Linux is extremely frustrating and the error messages are rarely useful. I feel your pain, man.

I encountered this relatively recently and my issue was that I had one too many “kerberos”-related pip packages installed and it somehow lead to winrm connectivity not working.

My currently working requirements.txt is

```auto
ansible==8.7.0
ansible-runner==2.4.0
pywinrm==0.4.3
pywinrm[kerberos]
receptorctl

```

I can’t account for why it used to work for you but no longer does, but it’s worth a shot.

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 1:20pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/4 "2024-11-14T13:20:31Z")

</div>

> [@motorbass](#):
>
> `AllowUnencrypted`

Before changing anything:

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

Then:

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

Indeed, it seems the encryption is clearly the issue:  
 ![image](https://us1.discourse-cdn.com/ansible/original/2X/b/b718a56f7a370bcdcee917fe63e2e109f8c2c78c.png)

As I want to keep everything encrypted, I restore the encryption:

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

So I retry the win\_ping on the server that does not support the encryption:

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

My questions:

- As I do not want to allow unencrypted transaction on thousands of servers, how can I fix this issue ?
- Why the server installed and configured a few months ago has no issues with encryption ?

Anyway, thank you for your help @motorbass

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [November 14, 2024, 1:23pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/5 "2024-11-14T13:23:01Z")

</div>

In addition to your test, @Iwan could you share your vars.yml or vars statement that configure ansible winRM settings please ?

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 1:31pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/6 "2024-11-14T13:31:39Z")

</div>

For testing purposes, I’m using a simple hosts file:

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

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

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [November 14, 2024, 1:32pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/7 "2024-11-14T13:32:48Z")

</div>

Ok i was 99% sure you were using 5985.  
5985 is for HTTP (so unencrypted) and 5986 is for HTTPS (so encrypted communication)

Could you give a try using `ansible_port=5986` ?

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 1:44pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/8 "2024-11-14T13:44:24Z")

</div>

The WinRM remains with the default configuration and listens on port 5985 only.

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

so:

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

My historic server works without any issue on port 5985 and mandatory encryption.

---

<div class="post-metadata">

**Author:** ![mariolenz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mariolenz/32/108_2.png) [@mariolenz](https://forum.ansible.com/u/mariolenz)\
**Post date:** [November 14, 2024, 1:59pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/9 "2024-11-14T13:59:48Z")

</div>

Why did you add the `vmware` tag? This doesn’t look like a VMware related issue at all, or am I wrong?

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [November 14, 2024, 2:01pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/10 "2024-11-14T14:01:36Z")

</div>

Ok, so as Microsoft said “_AllowUnencrypted : Allows the client computer to request unencrypted traffic_” so in our case, client requests only encrypted traffic.

So probably the error code 500 means : the windows target received the request but doesn’t process it well and/or ansible doesn’t understand it as it should.

So probably we should have a look at the Ansible venv.

I had a look to my windows vars for winrm, could you give a try using only :

```auto
ansible_connection: winrm
ansible_port: 5985
ansible_winrm_transport: kerberos

```

Depending on the result we’ll have a look to the ansible collection version, pip version, pip collections version.

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 2:33pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/11 "2024-11-14T14:33:50Z")

</div>

Indeed, it is clearly a mistake. It is not VMware related.

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 3:39pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/13 "2024-11-14T15:39:03Z")

</div>

As requested:

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

It is still not working

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 14, 2024, 4:23pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/14 "2024-11-14T16:23:35Z")

</div>

On the running server:

> ansible-core 2.17.3  
> certifi 2024.8.30  
> cffi 1.17.0  
> charset-normalizer 3.3.2  
> cryptography 43.0.0  
> decorator 5.1.1  
> gssapi 1.8.3  
> idna 3.8  
> Jinja2 3.1.4  
> jmespath 1.0.1  
> kerberos 1.3.1  
> krb5 0.6.0  
> MarkupSafe 2.1.5  
> packaging 24.1  
> pip 24.2  
> pycparser 2.22  
> pykerberos 1.2.4  
> pyspnego 0.11.1  
> pywinrm 0.5.0  
> PyYAML 6.0.2  
> requests 2.32.3  
> requests-kerberos 0.15.0  
> requests\_ntlm 1.3.0  
> resolvelib 1.0.1  
> urllib3 2.2.2  
> xmltodict 0.13.0

On the NOT running server:

> ansible-core 2.18.0  
> certifi 2024.8.30  
> cffi 1.17.1  
> charset-normalizer 3.4.0  
> cryptography 43.0.3  
> decorator 5.1.1  
> gssapi 1.9.0  
> idna 3.10  
> Jinja2 3.1.4  
> kerberos 1.3.1  
> krb5 0.7.0  
> MarkupSafe 3.0.2  
> packaging 24.2  
> pip 24.3.1  
> pycparser 2.22  
> pyspnego 0.11.2  
> pywinrm 0.5.0  
> PyYAML 6.0.2  
> requests 2.32.3  
> requests-kerberos 0.15.0  
> requests\_ntlm 1.3.0  
> resolvelib 1.0.1  
> urllib3 2.2.3  
> xmltodict 0.14.2

Not so different.

I’ve tried to install the pip packages from a ‘pip freeze’ on the running server, and install the very same version on the newly created server.  
It did not fix the issue…

My questions:

- Can it be related to the gcc version ? Some packages are built, and on the running server, they were built in July.
- Should I try to reinstall everything on an Ubuntu 22.04 so the GCC version is older ?
- Any other idea ? Suggestion ?

---

<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:** [November 14, 2024, 10:04pm UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/15 "2024-11-14T22:04:04Z")

</div>

I see you have both kerberos and pykerberos installed. Both of these packages use the same Python namespace `kerberos` but the `kerberos` package does not have the extra bits to enable message encryption. Uninstall both `kerberos` and `pykerberos` if they are present and just do `pip install pywinrm[kerberos]`. By mixing and matching you are disabling message encryption over HTTP causing the connection to fail.

---

<div class="post-metadata">

**Author:** ![Iwan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwan/32/5429_2.png) [@Iwan](https://forum.ansible.com/u/Iwan)\
**Post date:** [November 15, 2024, 8:28am UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/16 "2024-11-15T08:28:55Z")

</div>

> [@jborean](#):
>
> pywinrm[kerberos]

Big big thank you !

Here’d what I did:  
Before uninstalling anything

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

What i executed:

- pip uninstall kerberos pywinrm
- pip uninstall requests\_ntlm  
and then:
- pip install pywinrm[kerberos]  
 ![image](https://us1.discourse-cdn.com/ansible/original/2X/1/108c50112b9a901fa5cd1ad9c1a37f4ecf098e32.png)

And the final result:

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

You made my day !  
Thank you again ! 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 15, 2024, 8:29am UTC](https://forum.ansible.com/t/winrm-and-kerberos-winrm-connection-error-bad-http-response-returned-from-server-code-500/10908/17 "2024-12-15T08:29:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
