# Connection: local and Delegate\_to - Not working together

**URL:** <https://forum.ansible.com/t/connection-local-and-delegate-to-not-working-together/37162>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [September 30, 2022, 7:47pm UTC](https://forum.ansible.com/t/connection-local-and-delegate-to-not-working-together/37162 "2022-09-30T19:47:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 30, 2022, 7:47pm UTC](https://forum.ansible.com/t/connection-local-and-delegate-to-not-working-together/37162/1 "2022-09-30T19:47:24Z")

</div>

A few things,

The connection: keyword just changes the connection, while delegation  
changes the target host.

When using connection: local you end up executing on the controller  
(your connection is a local fork instead), not delegating to  
localhost, there is another step on that. Use delegate\_to: localhost  
is what you normally want to do.

if you delegate\_to: vm\_name but set connection to local, you are not  
really connecting to vm\_name (unless you are overriding the connection  
in other ways, like via connection variable). So they work together  
and did what you asked them to, it is just that what you asked them to  
do makes little sense.

---

<div class="post-metadata">

**Author:** ![Vichu](https://avatars.discourse-cdn.com/v4/letter/v/13edae/32.png) [@Vichu](https://forum.ansible.com/u/Vichu)\
**Post date:** [September 30, 2022, 8:51pm UTC](https://forum.ansible.com/t/connection-local-and-delegate-to-not-working-together/37162/2 "2022-09-30T20:51:55Z")

</div>

Hi Brain,

Can you elloborate the 3rd paragraph, so i can understand. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Vichu](https://avatars.discourse-cdn.com/v4/letter/v/13edae/32.png) [@Vichu](https://forum.ansible.com/u/Vichu)\
**Post date:** [September 30, 2022, 9:00pm UTC](https://forum.ansible.com/t/connection-local-and-delegate-to-not-working-together/37162/3 "2022-09-30T21:00:53Z")

</div>

[https://github.com/ansible/ansible/issues/71371](https://github.com/ansible/ansible/issues/71371)

Here is also a similiar problem but could not find a solution out of it
