# TimeOut

**URL:** <https://forum.ansible.com/t/timeout/31662>\
**Category:** Ansible Project\
**Created:** [November 14, 2019, 5:23pm UTC](https://forum.ansible.com/t/timeout/31662 "2019-11-14T17:23:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc-antoine\_Desroch](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@Marc-antoine\_Desroch](https://forum.ansible.com/u/Marc-antoine_Desroch)\
**Post date:** [November 14, 2019, 5:23pm UTC](https://forum.ansible.com/t/timeout/31662/1 "2019-11-14T17:23:57Z")

</div>

Here’s my problem:

I have to make a playbook to execute on a large range of servers but those servers can go down anytime, i can lose connection at any moment so i need ansible to be able to failed the job when the server gets unreachable.

Now when i execute a script on the remote server using the raw/shell module to execute a swupdate script if the connection is lost while the script is running i dont get any error and ansible just freeze there no failure or anything it just freeze while doing the tasks and nothing goes on. I tried modify the timeout values but nothing seems to work.

---

<div class="post-metadata">

**Author:** ![Soniya\_panwar](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Soniya\_panwar](https://forum.ansible.com/u/Soniya_panwar)\
**Post date:** [November 15, 2019, 11:31am UTC](https://forum.ansible.com/t/timeout/31662/2 "2019-11-15T11:31:56Z")

</div>

Hello Marc-antoine Desrochers,

To avoid such kind of problems you can add -o ServerAliveInterval=NumberOfSeconds in “[ssh\_connection]” from ansible.cfg.  
Add the following in your ansible.cfg:

`  
[ssh\_connection]

ssh\_args = -o ServerAliveInterval=n  
`

Here, n is the ServerAliveInterval (seconds) which we use while connecting to the server through SSH. Set it between 1-255. This will cause ssh client to send null packets to server every n seconds to avoid connection timeout.

Thanks Soniya
