Ansible - Resolve "unreachable could not resolve hostname name or service not known"

Let's say the following is returned when invoking the ad-hoc ansible command or ansible-playbook command. | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname Name or service not known",
    "unreachable": true


This suggests that the managed nodes hostname ( cannot be resolved to an IP address, which you can confirm using the nslookup command.

~]# nslookup

** server can't find NXDOMAIN


In this scenario, you would have to consult with the team in your organization that manages DNS (probably the networking team) to determine why DNS is unable to resolve the hostname to an IP address.

If you are just doing local testing, you can add an entry like this to the /etc/hosts file on your Ansible control node to resolve the hostname to an IP address.


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 8501a in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |