Ansible can't connect using the public DNS provided by AWS, but it can connect with the IP addr.

This issue is strange. If I use the public DNS provided by AWS, Ansible fails to connect (see error report below). But if I use the IP address it can connect and everything works.

Just to make sure, I can ssh into it (using either the IP or public DNS) without issues (providing the same username and key file than ansible is using).

I’ve tried everything and can’t seem to figure it out. Thanks in advance for your help.

Environment I’m running:

ansible 2.0.2.0 Mac OSX El Capitan (10.11.3)

Error:

Are you able to ssh to the desired host?

Although it’s not relevant but still can try, I have a problem with it in the past:

Edit ansible.cfg

[ssh_connection]
control_path = %(directory)s/%%h-%%r

But first thing is to check the ssh connection to the remote host.