# Connection refused despite proper credentials

**URL:** <https://forum.ansible.com/t/connection-refused-despite-proper-credentials/32639>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [April 9, 2020, 6:34am UTC](https://forum.ansible.com/t/connection-refused-despite-proper-credentials/32639 "2020-04-09T06:34:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaliyug\_Antagonist](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@Kaliyug\_Antagonist](https://forum.ansible.com/u/Kaliyug_Antagonist)\
**Post date:** [April 9, 2020, 6:34am UTC](https://forum.ansible.com/t/connection-refused-despite-proper-credentials/32639/1 "2020-04-09T06:34:02Z")

</div>

Tower 3.6.1  
Ansible 2.9.2

I am trying to execute a playbook that lists repositories in ( **on-prem** ) Bitbucket project. This playbook is in a separate repo. Note that the project to which this repo is linked shows ‘Update Succeeded’ and the template which uses this playbook is able to fetch it, for this, a credential ‘Source Control’ type is used which has the private key and Bitbucket has the public key.

```auto
# Create and configure repository playbook
---
- name: "List repos in a project"
  hosts: localhost
  connection: local
  vars:
    bitbucket_token: "{{ bb_admin_token }}"

  roles:
    - role: list_repos

```

The role:

```auto
---
- name: user_private_repositories
  uri:
    method: GET
    headers:
      Authorization: "Bearer {{ bitbucket_token }}"
    return_content: yes
    force_basic_auth: yes
    url: "{{ bitbucket_rest_url }}/{{ bitbucket.project.name }}/repos"
  register: bitbucketResponse

- name: show bitbucket reponse
  debug:
    msg: "{{ bitbucketResponse }}"
...

```

The inventory(it’s immaterial if the ‘Variables’ is left empty or the following entries are added, I still get the error):

`all: hosts: localhost 127.0.0.1`

 ![Inventory.png](https://us1.discourse-cdn.com/ansible/original/2X/b/bda417542914cc9360edd8ac3e047f52bc5aaf12.png)

The template execution:

`ansible-playbook 2.9.2 config file = /etc/ansible/ansible.cfg configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible-playbook python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] Using /etc/ansible/ansible.cfg as config file PLAYBOOK: list_operations_playbook.yml *****************************************1 plays in list_operations_playbook.yml PLAY [List repos in a project]************************************************* TASK [Gathering Facts] *********************************************************task path: /tmp/awx_897_usiyawjw/project/list_operations_playbook.yml:3 ok: [localhost] META: ran handlers TASK [list_repos : user_private_repositories]********************************** task path: /tmp/awx_897_usiyawjw/project/roles/list_repos/tasks/main.yml:2 fatal: [localhost]: FAILED! => {"changed": false, "content": "", "elapsed": 0, "msg": "Status code was -1 and not [200]: Request failed: <urlopen error [Errno 111] Connection refused>", "redirected": false, "status": -1, "url": "https://git.company.net/rest/api/1.0/projects/~p950ojb/repos"} PLAY RECAP ********************************************************************* localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0`

What am I missing?

---

<div class="post-metadata">

**Author:** ![Kaliyug\_Antagonist](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@Kaliyug\_Antagonist](https://forum.ansible.com/u/Kaliyug_Antagonist)\
**Post date:** [April 9, 2020, 7:36am UTC](https://forum.ansible.com/t/connection-refused-despite-proper-credentials/32639/2 "2020-04-09T07:36:46Z")

</div>

Adding output with verbosity ‘4: Connection Debug’ (since cannot edit the original post)

`  
ansible-playbook 2.9.2  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/var/lib/awx/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]  
Using /etc/ansible/ansible.cfg as config file  
setting up inventory plugins  
host\_list declined parsing /tmp/awx\_903\_n07j1ejc/tmpyzzhv20e as it did not pass its verify\_file() method  
Set default localhost to localhost  
Parsed /tmp/awx\_903\_n07j1ejc/tmpyzzhv20e inventory source with script plugin  
Loading callback plugin awx\_display of type stdout, v2.0 from /var/lib/awx/venv/awx/lib/python3.6/site-packages/ansible\_runner/callbacks/awx\_display.py

PLAYBOOK: list\_operations\_playbook.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Positional arguments: list\_operations\_playbook.yml  
diff: True  
remote\_user: root  
become\_method: sudo  
inventory: (u’/tmp/awx\_903\_n07j1ejc/tmpyzzhv20e’,)  
forks: 5  
tags: (u’all’,)  
extra\_vars: (u’@/tmp/awx\_903\_n07j1ejc/env/extravars’,)  
verbosity: 4  
connection: smart  
timeout: 30  
1 plays in list\_operations\_playbook.yml

PLAY [List repos in a project] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /tmp/awx\_903\_n07j1ejc/project/list\_operations\_playbook.yml:3  
 ESTABLISH LOCAL CONNECTION FOR USER: awx  
 EXEC /bin/sh -c ‘echo ~awx && sleep 0’  
 EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371`” && echo ansible-tmp-1586417248.74-71622462422371=“`echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371`” ) && sleep 0’  
 Attempting python interpreter discovery  
 EXEC /bin/sh -c ‘echo PLATFORM; uname; echo FOUND; command -v ‘"’"’/usr/bin/python’“'”‘; command -v ‘"’“‘python3.7’”’“'; command -v '”‘“‘python3.6’”’“'; command -v '”‘“‘python3.5’”’“'; command -v '”‘“‘python2.7’”’“'; command -v '”‘“‘python2.6’”’“'; command -v '”‘"’/usr/libexec/platform-python’“'”‘; command -v ‘"’"’/usr/bin/python3’“'”‘; command -v ‘"’“‘python’”’"‘; echo ENDFOUND && sleep 0’  
 EXEC /bin/sh -c ‘/usr/bin/python && sleep 0’  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py  
 PUT /var/lib/awx/.ansible/tmp/ansible-local-4904nN1BfG/tmpCC6Gr4 TO /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/AnsiballZ\_setup.py  
 EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/ /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/AnsiballZ\_setup.py && sleep 0’  
 EXEC /bin/sh -c ‘/usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/AnsiballZ\_setup.py && sleep 0’  
 EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/ \> /dev/null 2\>&1 && sleep 0’  
ok: [localhost]  
META: ran handlers

TASK [list\_repos : user\_private\_repositories] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /tmp/awx\_903\_n07j1ejc/project/roles/list\_repos/tasks/main.yml:2  
 ESTABLISH LOCAL CONNECTION FOR USER: awx  
 EXEC /bin/sh -c ‘echo ~awx && sleep 0’  
 EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541`” && echo ansible-tmp-1586417251.05-52017934597541=“`echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541`” ) && sleep 0’  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/net\_tools/basics/uri.py  
 PUT /var/lib/awx/.ansible/tmp/ansible-local-4904nN1BfG/tmpsEAI5j TO /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/AnsiballZ\_uri.py  
 EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/ /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/AnsiballZ\_uri.py && sleep 0’  
 EXEC /bin/sh -c ‘/usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/AnsiballZ\_uri.py && sleep 0’  
 EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/ \> /dev/null 2\>&1 && sleep 0’  
fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“content”: “”,  
“elapsed”: 0,  
“invocation”: {  
“module\_args”: {  
“attributes”: null,  
“backup”: null,  
“body”: null,  
“body\_format”: “raw”,  
“client\_cert”: null,  
“client\_key”: null,  
“content”: null,  
“creates”: null,  
“delimiter”: null,  
“dest”: null,  
“directory\_mode”: null,  
“follow”: false,  
“follow\_redirects”: “safe”,  
“force”: false,  
“force\_basic\_auth”: true,  
“group”: null,  
“headers”: {  
“Authorization”: “Bearer token-here”  
},  
“http\_agent”: “ansible-httpget”,  
“method”: “GET”,  
“mode”: null,  
“owner”: null,  
“regexp”: null,  
“remote\_src”: null,  
“removes”: null,  
“return\_content”: true,  
“selevel”: null,  
“serole”: null,  
“setype”: null,  
“seuser”: null,  
“src”: null,  
“status\_code”: [  
200  
],  
“timeout”: 30,  
“unix\_socket”: null,  
“unsafe\_writes”: null,  
“url”: “[https://git.company.net/rest/api/1.0/projects/~p950ojb/repos](https://git.company.net/rest/api/1.0/projects/~p950ojb/repos)”,  
“url\_password”: null,  
“url\_username”: null,  
“use\_proxy”: true,  
“validate\_certs”: true  
}  
},  
“msg”: “Status code was -1 and not [200]: Request failed: \<urlopen error [Errno 111] Connection refused\>”,  
“redirected”: false,  
“status”: -1,  
“url”: “[https://git.company.net/rest/api/1.0/projects/~p950ojb/repos](https://git.company.net/rest/api/1.0/projects/~p950ojb/repos)”  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

`
