# Control socket connect(...): Connection refused

**URL:** <https://forum.ansible.com/t/control-socket-connect-connection-refused/18462>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [June 10, 2015, 6:13pm UTC](https://forum.ansible.com/t/control-socket-connect-connection-refused/18462 "2015-06-10T18:13:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Traun\_Leyden](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Traun\_Leyden](https://forum.ansible.com/u/Traun_Leyden)\
**Post date:** [June 10, 2015, 6:13pm UTC](https://forum.ansible.com/t/control-socket-connect-connection-refused/18462/1 "2015-06-10T18:13:57Z")

</div>

I’m running ansible on Ubuntu 14.04.2 LTS running OpenSSH\_6.6.1p1 inside of a Docker container with a CoreOS host, and running this command as root:

> ansible key\_tleyden -i inventory -m ping -u centos -vvvv

and seeing this error:

[ec2-52-152-154-133.compute-1.amazonaws.com](http://ec2-52-152-154-133.compute-1.amazonaws.com) | FAILED =\> SSH Error: debug2: set\_control\_persist\_exit\_time: schedule exit in 60 seconds  
while connecting to 10.152.151.154:22

After quite a lot of digging (I wish ansible gave a clearer error message here), it seemed to be related to SSH ControlPersist, so I tried running this command (also as root):

> ssh -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=$CP [centos@10.119.181.141](mailto:centos@10.119.181.141)

and with that I get the error:

> Control socket connect(/root/.ansible/cp/ansible-ssh-10.119.181.141-22-centos): Connection refused

I can see the domain socket here:

srw------- 1 root root 0 Jun 10 18:11 ansible-ssh-ec2-54-157-151-133.compute-1.amazonaws.com-22-centos

but am unclear on why ssh can’t seem to use it.

If I change my ansible.cfg to disable the ControlPersist settings via:

> [ssh\_connection]
> 
> ssh\_args =

Then the ansible errors completely go away.

---

<div class="post-metadata">

**Author:** ![Traun\_Leyden](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Traun\_Leyden](https://forum.ansible.com/u/Traun_Leyden)\
**Post date:** [June 10, 2015, 7:01pm UTC](https://forum.ansible.com/t/control-socket-connect-connection-refused/18462/2 "2015-06-10T19:01:48Z")

</div>

So far this is looking like a really obscure CoreOS issue. I tried against Ubuntu running inside a Docker container on an Ubuntu host, and couldn’t reproduce this. Sorry for the noise. (but any insight would still be welcome)

---

<div class="post-metadata">

**Author:** ![Nel\_Roque](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@Nel\_Roque](https://forum.ansible.com/u/Nel_Roque)\
**Post date:** [January 12, 2016, 10:54am UTC](https://forum.ansible.com/t/control-socket-connect-connection-refused/18462/3 "2016-01-12T10:54:45Z")

</div>

Please check:

[https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1262287](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1262287)

In a nutshell, the latest ssh versions and overlayfs don’t play well together, after much trouble I just configured the ControlPath ssh option to point to a tmpfs path inside the docker container and voilá.

I’m using the castawaylabs/semaphore docker image on CoreOS stable (835.9.0)

Cheers

---

<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 12, 2016, 1:37pm UTC](https://forum.ansible.com/t/control-socket-connect-connection-refused/18462/4 "2016-01-12T13:37:50Z")

</div>

@Nel, thanks for figuring this one out, this seems like a pretty nasty bug.

---

<div class="post-metadata">

**Author:** ![WhileLoop](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@WhileLoop](https://forum.ansible.com/u/WhileLoop)\
**Post date:** [December 8, 2016, 4:35am UTC](https://forum.ansible.com/t/control-socket-connect-connection-refused/18462/5 "2016-12-08T04:35:30Z")

</div>

I can confirm changing the the control path to a tmpfs location fixed the problem for me. In my case I used /dev.
