Learn how to fix “[Errno 101] Network is Unreachable” in Ansible. Our DevOps Support team is here to help you with your questions and concerns.
How to Fix “[Errno 101] Network is Unreachable” in Ansible
When you see the error “[Errno 101] Network is unreachable,” it usually means that your system cannot communicate with a remote destination. This may be due to firewall rules, incorrect network settings, or a lack of internet access.
If we run into this error in Ansible, it means that the control node cannot establish a connection with the managed node, which disrupts automation workflows.
Here is a look at the error message:
fatal: [ansible-target]: FAILED! => changed=false msg: ‘Failed to connect to at port 443: [Errno 101] Network is unreachable’
This error message indicates that the Ansible control node cannot reach the target machine. Some of the possible causes include incorrect routing, blocked ports, or DNS misconfiguration.
Impacts of “[Errno 101] Network is Unreachable”
- The program fails to access required resources or communicate with other systems.
- In Ansible, playbooks halt when a host is unreachable.
- The error can prevent password reset emails from being sent.
- Execution of playbooks may be delayed if Ansible continuously attempts to reconnect.
- Remote resources such as repositories, databases, and file servers may become inaccessible.
- In large environments, unreachable nodes can disrupt orchestration and provisioning.
Causes and Fixes – “[Errno 101] Network is Unreachable”
1. Network Connectivity Issues
The system may be unable to reach the destination due to network problems, such as incorrect IP settings or an inactive internet connection.
Click here for the Solution.
- First, check internet connectivity:
ping 8.8.8.8
- Then, test DNS resolution:
nslookup host_name
- Next, verify the routing table:
ip route show
- Also, correct any misconfigurations in `/etc/resolv.conf` or `/etc/network/interfaces`.
- Finally, retest connectivity using `ping` or `traceroute`.
2. Firewall Blocking Ports
Firewalls may block required ports, preventing the connection.
Click here for the Solution.
- To begin with, check firewall settings:
sudo iptables -L
- Allow outbound traffic on required ports (e.g., 443 for HTTPS):
sudo iptables -A OUTPUT -p tcp –dport 443 -j ACCEPT
- If using `firewalld`, open the port:
sudo firewall-cmd –add-port=443/tcp –permanent sudo firewall-cmd –reload
- Also, ensure that firewall settings on the target host allow necessary traffic.
- Retry the Ansible playbook.
3. Incorrect SSH Configuration
This error can occur if Ansible uses SSH to communicate with the target node and the SSH settings are incorrect.
Click here for the Solution.
- Verify the SSH configuration in the `ansible.cfg` and inventory files.
- Test SSH manually:
ssh user@target-host
- Then, ensure SSH keys are correctly placed and permissions are set.
- Also, reconfigure SSH settings or regenerate keys if necessary.
- Test with:
ansible all -m ping
4. Proxy Configuration Issues
If the system or Ansible is behind a proxy and the settings are incorrect, it can prevent connections.
Click here for the Solution.
- First, set proxy environment variables:
export http_proxy=http://proxy.example.com:8080 export https_proxy=http://proxy.example.com:8080
- Then, verify that the proxy allows traffic to the target destination.
- Ensure proxy settings in Ansible are configured correctly.
- Next, test the connection manually using `curl` or `wget`.
- Finally, retry the Ansible connection after confirming the proxy settings.
5. Ansible Configuration Errors
Incorrect inventory files or misconfigured settings in `ansible.cfg` can cause unreachable errors.
Click here for the Solution.
- First, verify the inventory file’s accuracy.
- Test connectivity manually:
ansible all -m ping
- If using dynamic inventory, ensure it generates correct output.
- Then, confirm the SSH and connection settings in `ansible .cfg`.
- Finally, retry the playbook.
Prevention Measures
- Monitor network and firewall settings to ensure that the required ports remain open.
- Use Ansible to manage network and firewall settings for consistency.
- Regularly verify DNS resolution, routing, and network configurations.
- Set up logging on network devices to detect and resolve issues early.
- Periodically check SSH access, repository connectivity, and DNS resolution.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
The “[Errno 101] Network is unreachable” error in Ansible is commonly caused by network misconfigurations, firewall restrictions, or SSH-related issues.
In brief, our Support Experts demonstrated how to fix “[Errno 101] Network is Unreachable” in Ansible.
0 Comments