`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: ssh: connect to host web01 port 22: Connection refused"}`
BeginnerTroubleshootingConnection and SSH Failures
Answer
Likely causes → sshd is not running, listens on another port, or the host is still booting.
Diagnose →
nc -vz web01 22
ssh -p 2222 user@web01 # test an alternate port
# on the host console: systemctl status sshd; ss -tlnp | grep ssh
Fix → Start sshd, or set ansible_port in inventory. After provisioning use wait_for_connection or wait_for on port 22.
Prevent → Add a wait step in provisioning playbooks.
More on Connection and SSH Failures
`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password)."}`Beginner`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: ssh: connect to host 10.0.1.15 port 22: Connection timed out"}`Beginner`Host key verification failed.` after rebuilding a serverBeginnerThe playbook hangs for ever at "Gathering Facts" on one hostIntermediate`Failed to connect to the host via ssh: Too many authentication failures`Intermediate`fatal: [web01]: UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: Shared connection to web01 closed."}` mid-runIntermediate