# Strage behaviour related to localhost in ansible 2.2

**URL:** <https://forum.ansible.com/t/strage-behaviour-related-to-localhost-in-ansible-2-2/23487>\
**Category:** Ansible Project\
**Created:** [January 18, 2017, 9:47am UTC](https://forum.ansible.com/t/strage-behaviour-related-to-localhost-in-ansible-2-2/23487 "2017-01-18T09:47:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://forum.ansible.com/u/Stefan_Magnus_Landro)\
**Post date:** [January 18, 2017, 9:47am UTC](https://forum.ansible.com/t/strage-behaviour-related-to-localhost-in-ansible-2-2/23487/1 "2017-01-18T09:47:20Z")

</div>

Hi all,

Can anyone explain why targeting localhost explicitly instead of defaulting to localhost behaves differently?

Cheers,

Stefan

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 19, 2017, 12:00am UTC](https://forum.ansible.com/t/strage-behaviour-related-to-localhost-in-ansible-2-2/23487/2 "2017-01-19T00:00:58Z")

</div>

Ansible creates an implicit localhost when it is used, but not defined in inventory. The implicit localhost sets connection to ‘local’, among other things.

When you define localhost, it inherits the default connection type (‘smart/ssh’ unless you changed config), so you need to either define the connection for the host/command line/play/task/config.
