The "ssh_init: host does not exist" error occurs when SSH cannot resolve the hostname. This is often due to outdated DNS cache, meaning your computer is trying to use old or incorrect DNS records.
Flushing the DNS cache forces your system to retrieve fresh DNS records, which can resolve hostname-related SSH issues.
Win + X, then select "Windows Terminal (Admin)" or "Command Prompt (Admin)".ipconfig /flushdns
You should see: "Successfully flushed the DNS Resolver Cache."
ssh user@yourserver.com
Now Windows should retrieve fresh DNS records for your SSH connection.
sudo killall -HUP mDNSResponder
You may be prompted for your administrator password.
ssh user@yourserver.com
macOS will now use updated DNS records for hostname resolution.
The command varies depending on your Linux distribution and the DNS resolver it uses.
sudo systemd-resolve --flush-caches
sudo systemctl restart nscd
# Using systemd-resolved (most common)
sudo systemctl restart systemd-resolved
# Using resolvectl (alternative)
sudo resolvectl flush-caches
After running the appropriate command for your distribution, Linux should resolve SSH hostnames correctly with fresh DNS data.
After flushing DNS, restarting your network interface can help apply all changes completely.
In Command Prompt (Admin):
ipconfig /release
ipconfig /renew
# For systems with systemd networking
sudo systemctl restart networking
# For systems using NetworkManager (common on desktops)
nmcli networking off && nmcli networking on
After flushing the DNS cache, test if your system can now resolve the SSH hostname correctly.
nslookup yourserver.com
dig yourserver.com
or
host yourserver.com
What to Look For:
192.168.1.10), DNS is working properly."NXDOMAIN", "No answer", or "Host not found", DNS is still failing and you may need additional fixes.If DNS resolution still fails after flushing the cache, you can manually map the hostname to its IP address. This bypasses DNS entirely.
sudo nano /etc/hosts
192.168.1.10 yourserver.com
ssh user@yourserver.com
C:\Windows\System32\drivers\etc\hosts
192.168.1.10 yourserver.com
| Issue | Fix |
|---|---|
| Hostname not resolving (ssh_init: host does not exist) | Use IP instead of hostname for immediate connection |
| Old DNS cache is causing issues | Flush DNS with ipconfig /flushdns (Windows) or systemd-resolve --flush-caches (Linux) |
| Network using outdated DNS records | Restart networking with systemctl restart networking |
| DNS resolution still failing after flush | Manually add hostname to /etc/hosts or C:\Windows\System32\drivers\etc\hosts |
| Firewall blocking SSH | Ensure port 22 is open with ufw allow 22/tcp (server-side) |
By following these steps, SSH should work without the "ssh_init: host does not exist" error!