# Connection to Target server Failing

**URL:** <https://forum.ansible.com/t/connection-to-target-server-failing/33503>\
**Category:** Ansible Project\
**Created:** [July 27, 2020, 4:26pm UTC](https://forum.ansible.com/t/connection-to-target-server-failing/33503 "2020-07-27T16:26:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GOPABANDHU\_DASH](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@GOPABANDHU\_DASH](https://forum.ansible.com/u/GOPABANDHU_DASH)\
**Post date:** [July 27, 2020, 4:26pm UTC](https://forum.ansible.com/t/connection-to-target-server-failing/33503/1 "2020-07-27T16:26:24Z")

</div>

Hi,

I am getting below error when i am trying to connect to my target server

fatal: [hostname]: FAILED! =\> {“changed”: false, “module\_stderr”: “Connection to hostname closed.\r\n”, “module\_stdout”: " File "/home/gopa/.ansible/tmp/ansible-tmp-1595866958.593897-39491564121298/AnsiballZ\_setup.py", line 39\r\n with open(module, ‘wb’) as f:\r\n ^\r\nSyntaxError: invalid syntax\r\n", “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}

My target having python 2.7.2 version.

Also i tried by setting remote\_tmp = /tmp/ansible-$USER. Also getting the same issue.

Please help

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 27, 2020, 9:14pm UTC](https://forum.ansible.com/t/connection-to-target-server-failing/33503/2 "2020-07-27T21:14:07Z")

</div>

Ansible version?

Target os?  
Playbook?  
Invocation and arguments?  
Inventory?

Please send

---

<div class="post-metadata">

**Author:** ![GOPABANDHU\_DASH](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@GOPABANDHU\_DASH](https://forum.ansible.com/u/GOPABANDHU_DASH)\
**Post date:** [July 27, 2020, 11:23pm UTC](https://forum.ansible.com/t/connection-to-target-server-failing/33503/3 "2020-07-27T23:23:53Z")

</div>

Issue got resolved after changing the **ansible\_python\_interpreter=/usr/local/bin/python. I** am using redhat version 5 where two different python version python2.4 and python2.7 is available. Python2.4 is in default location /usr/bin and python2.7 is in /usr/local/bin/python. After some research i found ansible automatic use the default interpreter which is /usr/bin that the reason i was getting issue After changing that variable issue got resolved.

Anyway Thanks for the quick response. Really appreciated.
