HTTP connection refused errors

I am running AWX using Docker on a Cent OS 7 host.

I have a playbook that uses the script module to run a python script on the localhost to make HTTP GET requests using the AWX REST API.

But the awx_task container cannot make connections to complete the request and I get the following error on stdout.
If I exec into the container and run the playbook, I get this same error -

`

{
“changed”: false,
“_ansible_verbose_always”: true,
“_ansible_no_log”: false,
“response”: {
“stdout”: “HTTPConnectionPool(host=‘localhost’, port=80): Max retries exceeded with url: /api/v2/teams/ (Caused by NewConnectionError(‘<requests.packages.urllib3.connection.HTTPConnection object at 0x18f56d0>: Failed to establish a new connection: [Errno 111] Connection refused’,))\n”,
“changed”: true,
“failed”: false,
“stderr”: “”,
“rc”: 0,
“stdout_lines”: [
“HTTPConnectionPool(host=‘localhost’, port=80): Max retries exceeded with url: /api/v2/teams/ (Caused by NewConnectionError(‘<requests.packages.urllib3.connection.HTTPConnection object at 0x18f56d0>: Failed to establish a new connection: [Errno 111] Connection refused’,))”
]
}
}

`

These are my proxy settings in the AWX inventory file -

`

Proxy

http_proxy=http://proxy:3128

https_proxy=http://proxy:3128

no_proxy=mycorp.org

`

I can get out to the internet from the awx_task container. How can I fix this connection error?

Do you have a firewall, I see connection refuse error which can be because of firewall blocking specific port. Or try putting a rule for port in iptables.

To clarify, my Cent OS “host” is actually a VM being NATted on a Windows box. I see these chains on Cent OS -

`

Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp – anywhere 172.17.0.5 tcp dpt:senomix01

Chain DOCKER-ISOLATION (1 references)
target prot opt source destination
RETURN all – anywhere anywhere

Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all – anywhere anywhere

`

But since I’m making HTTP requests to localhost, the awx_task docker container would talk to itself. If I run ‘iptables -L’ i get this -

`

iptables v1.4.21: can’t initialize iptables table `filter’: Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.

`

iptables is already on the latest version -
`
Package iptables-1.4.21-18.3.el7_4.x86_64 already installed and latest version

`

kernel version is -

`
3.10.0-693.21.1.el7.x86_64

`