# ANSIBLE randomly fails to connect to hosts behind bastion

**URL:** <https://forum.ansible.com/t/ansible-randomly-fails-to-connect-to-hosts-behind-bastion/31150>\
**Category:** Ansible Project\
**Created:** [August 28, 2019, 10:34am UTC](https://forum.ansible.com/t/ansible-randomly-fails-to-connect-to-hosts-behind-bastion/31150 "2019-08-28T10:34:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto\_Jimenez\_Loza](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Alberto\_Jimenez\_Loza](https://forum.ansible.com/u/Alberto_Jimenez_Loza)\
**Post date:** [August 28, 2019, 10:34am UTC](https://forum.ansible.com/t/ansible-randomly-fails-to-connect-to-hosts-behind-bastion/31150/1 "2019-08-28T10:34:53Z")

</div>

I use a proxy to connect to some machines and therefore I use the variable **ansible\_ssh\_common\_args.**

**vars:**  
**ansible\_ssh\_common\_args: ‘-o ProxyCommand=“/usr/bin/nc --proxy-type socks5 --proxy xxxxxxxxxx:1080 %h %p”’**

I found that the playbook radomly fails in a different machine of the inventory with this error:

**{**  
**“msg”: “Failed to connect to the host via ssh: Connection timed out during banner exchange\r\n”,**  
**“unreachable”: true,**  
**“changed”: false**  
**}**

If I retry the execution of the playbook, it fails in another machine with the same error, and the previous sever with errors ends ok.

I tried to change SSH parameters in the proxy bastion, but it fails too.

MaxStartups

MaxSessions

I solved the problem with option fork 1 and thus the playbook allways ends OK.

But I have a new problem. when I execute two playbooks with proxy simultaneously, it appears ramdoly error.

Is there any solution?

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [August 28, 2019, 11:03am UTC](https://forum.ansible.com/t/ansible-randomly-fails-to-connect-to-hosts-behind-bastion/31150/2 "2019-08-28T11:03:53Z")

</div>

FWIW. It might be more efficient to clone the master inside the cluster and  
avoid the proxy. This would also speedup the playbooks.

Cheers,

&nbsp;&nbsp;-vlado
