# Ansible AWS EC2 create scripts gives this error:: "Timeout when waiting for 172.31.25.6:22"}

**URL:** <https://forum.ansible.com/t/ansible-aws-ec2-create-scripts-gives-this-error-timeout-when-waiting-for-172-31-25-6-22/26273>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 13, 2017, 4:56am UTC](https://forum.ansible.com/t/ansible-aws-ec2-create-scripts-gives-this-error-timeout-when-waiting-for-172-31-25-6-22/26273 "2017-12-13T04:56:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Sharma1](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Ajay\_Sharma1](https://forum.ansible.com/u/Ajay_Sharma1)\
**Post date:** [December 13, 2017, 4:56am UTC](https://forum.ansible.com/t/ansible-aws-ec2-create-scripts-gives-this-error-timeout-when-waiting-for-172-31-25-6-22/26273/1 "2017-12-13T04:56:47Z")

</div>

My Ansible AWS EC2 instance creation script gives this error.

"Timeout when waiting for 172.31.25.6:22"}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to retry, use: --limit @/root/instance/provision-ec2.retry

this code is causing problem, Please let me know, how to solve this.

\*- name: Wait for the instances to boot by checking the ssh port wait\_for: host={{item.public\_ip}} port=22 delay=60 timeout=220 state=started with\_items: "{{ ec2.instances }}" ~ \*  
here is the entire code.

---

<div class="post-metadata">

**Author:** ![alanpassel7](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@alanpassel7](https://forum.ansible.com/u/alanpassel7)\
**Post date:** [December 18, 2017, 4:46am UTC](https://forum.ansible.com/t/ansible-aws-ec2-create-scripts-gives-this-error-timeout-when-waiting-for-172-31-25-6-22/26273/2 "2017-12-18T04:46:17Z")

</div>

What happens if you increase the delay?

---

<div class="post-metadata">

**Author:** ![Ajay\_Sharma1](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Ajay\_Sharma1](https://forum.ansible.com/u/Ajay_Sharma1)\
**Post date:** [December 18, 2017, 6:26am UTC](https://forum.ansible.com/t/ansible-aws-ec2-create-scripts-gives-this-error-timeout-when-waiting-for-172-31-25-6-22/26273/3 "2017-12-18T06:26:20Z")

</div>

If i increase the delay, in that condition also, it gives the same error.

when i ran the above scripts in ansible-playbook --check debug option.

it gave this error

fatal: [localhost]: FAILED! =\> {“msg”: “‘dict object’ has no attribute ‘instances’”}  
to retry, use: --limit @/root/instance/provision-ec2.retry

so i commented this part in the main.yml file, and now it runs ok, but does not wait for the machine to come up.

# - debug: var=item

# with\_items: “{{ ec2.instances }}”

# - add\_host: name={{ item.public\_ip }} \>

# groups=tag\_Type\_{{ec2\_tag\_Type}},tag\_Environment\_{{ec2\_tag\_Environment}}

# ec2\_region={{ec2\_region}}

# ec2\_tag\_Name={{ec2\_tag\_Name}}

# ec2\_tag\_Type={{ec2\_tag\_Type}}

# ec2\_tag\_Environment={{ec2\_tag\_Environment}}

# ec2\_ip\_address={{item.public\_ip}}

# with\_items: “{{ ec2.instances }}”

# - name: Wait for the instances to boot by checking the ssh port

# wait\_for: host={{item.public\_ip}} port=22 delay=60 timeout=320 state=started

# with\_items: “{{ ec2.instances }}”

now it runs Ok. but does not waits for the machine to come up.
