connection refused to "localhost" with paramiko

I ran into a strange issue with the paramiko tranpsort today.

I launched a vagrant instance on my local machine (ssh port defaults to 2222). I created a hosts file that looks like this:

vagrant ansible_ssh_port=2222 ansible_ssh_host=localhost

My config file looks like this:

[defaults]
hostfile = hosts
remote_user = vagrant
private_key_file = /Users/lorin/.vagrant.d/insecure_private_key

If I try to connect to with paramiko, I get connection refused:

$ ansible vagrant -m ping
vagrant | FAILED => FAILED: [Errno 61] Connection refused

Works fine with native ssh as the transport layer:

$ ansible vagrant -m ping -c ssh
vagrant | success >> {
“changed”: false,
“ping”: “pong”
}

It also works fine with paramiko if I change ansible_ssh_host to “127.0.0.1”, like so:

vagrant ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1

$ ansible vagrant -m ping
vagrant | success >> {
“changed”: false,
“ping”: “pong”
}

Anyone know why paramiko succeeds on “127.0.0.1” but fails on “localhost” in this situation? I’m running off of the devel branch:

$ ansible --version
ansible 1.1 (devel 304c447bd2) last updated 2013/03/31 16:57:58 (GMT -400)

I’m using paramiko 1.10.0.

Lorin

I do not have that problem here, I'd assume it is an entirely
legitimate connection failed message.

I had similar issues and it had to do with an IPv6 localhost entry. Removing it resolved the issue (I wasn’t using IPv6 anyways).