Fixing "ssh_init: host does not exist" — Flush DNS Cache
1. Flush DNS Cache on Windows
- Open Command Prompt as Administrator:
- Press
Win + X, then select "Windows Terminal (Admin)" or "Command Prompt (Admin)".
- Press
- Run the flush command:
You should see:ipconfig /flushdns"Successfully flushed the DNS Resolver Cache." - Restart your SSH connection:
ssh user@yourserver.com
Now Windows should retrieve fresh DNS records for your SSH connection.
For closely related ssh_init / FileZilla topics, see Use IP Instead of Hostname, systemd-resolved Linux, and ssh_init Host Does Not Exist (general).
2. Flush DNS Cache on macOS
- Open Terminal (Applications > Utilities > Terminal).
- Run the flush command:
You may be prompted for your administrator password.sudo killall -HUP mDNSResponder - Restart SSH:
ssh user@yourserver.com
macOS will now use updated DNS records for hostname resolution.
3. Flush DNS Cache on Linux
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.
4. Restart Your Network Connection
After flushing DNS, restarting your network interface can help apply all changes completely.
Restart Network in Windows
In Command Prompt (Admin):
ipconfig /release
ipconfig /renew
Restart Network in Linux/macOS
# For systems with systemd networking
sudo systemctl restart networking
# For systems using NetworkManager (common on desktops)
nmcli networking off && nmcli networking on
5. Verify DNS Resolution
After flushing the DNS cache, test if your system can now resolve the SSH hostname correctly.
Windows: Test with nslookup
nslookup yourserver.com
Linux/macOS: Test with dig or host
dig yourserver.com
or
host yourserver.com
What to Look For:
- Success: If the result shows an IP address (e.g.,
192.168.1.10), DNS is working properly. - Failure: If it says
"NXDOMAIN","No answer", or"Host not found", DNS is still failing and you may need additional fixes.
6. Add the SSH Host to Hosts File (Manual Fix)
If DNS resolution still fails after flushing the cache, you can manually map the hostname to its IP address. This bypasses DNS entirely.
Linux/macOS
- Edit the hosts file:
sudo nano /etc/hosts - Add this line at the end (use your actual IP and hostname):
192.168.1.10 yourserver.com - Save (Ctrl+O) and exit (Ctrl+X).
- Retry SSH:
ssh user@yourserver.com
Windows
- Open Notepad as Administrator.
- Click File > Open and navigate to:
C:\Windows\System32\drivers\etc\hosts - Add this line at the end of the file:
192.168.1.10 yourserver.com - Save the file and restart your SSH client.
7. Summary of Fixes
| 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!


