I wonder if there may be an underlying networking issue with the Github runners being used. I have run into this problem several times in the last few months. I have an ansible playbook that sets up a test environment for pull requests. There could be 2 or 3 of these running at a time and they are all targeting the same server.
I get the connection error intermittently. Previously I was using the above mentioned run-ansible-playbook action and I switched to just using the built in ansible-playbook cli that comes bundled with the Ubuntu runner image. The error occurs regardless of which method I use and simply re-running the failed action resolves the issue.