Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Fixing "ssh_init: host does not exist" — Flush DNS Cache

3 min read
04.09.2025

1. Flush DNS Cache on Windows

Windows: Flush DNS with ipconfig
  1. Open Command Prompt as Administrator:
    • Press Win + X, then select "Windows Terminal (Admin)" or "Command Prompt (Admin)".
  2. Run the flush command:
    ipconfig /flushdns
    You should see: "Successfully flushed the DNS Resolver Cache."
  3. Restart your SSH connection:
    ssh user@yourserver.com

Now Windows should retrieve fresh DNS records for your SSH connection.

SSH Flush DNS Cache
ssh_init DNS-stale — flush per-OS; quick and harmless.

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

macOS: Flush DNS with mDNSResponder
  1. Open Terminal (Applications > Utilities > Terminal).
  2. Run the flush command:
    sudo killall -HUP mDNSResponder
    You may be prompted for your administrator password.
  3. Restart SSH:
    ssh user@yourserver.com

macOS will now use updated DNS records for hostname resolution.

Linux VDS
High performance for your projects
  • Root access and flexible setup
  • Control panel
  • NVMe disks
  • DDR5
Linux VDS

3. Flush DNS Cache on Linux

The command varies depending on your Linux distribution and the DNS resolver it uses.

For Ubuntu/Debian (systemd-based)
sudo systemd-resolve --flush-caches
For CentOS/RHEL (nscd-based - Name Service Cache Daemon)
sudo systemctl restart nscd
Universal Linux Commands (Modern Systems)
# 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

  1. Edit the hosts file:
    sudo nano /etc/hosts
  2. Add this line at the end (use your actual IP and hostname):
    192.168.1.10 yourserver.com
  3. Save (Ctrl+O) and exit (Ctrl+X).
  4. Retry SSH:
    ssh user@yourserver.com

Windows

  1. Open Notepad as Administrator.
  2. Click File > Open and navigate to:
    C:\Windows\System32\drivers\etc\hosts
  3. Add this line at the end of the file:
    192.168.1.10 yourserver.com
  4. 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!

Frequently asked questions
Browser uses its own internal DNS cache PLUS the OS resolver. SSH uses OS resolver only. Browser cache hits with cached value while OS cache still serves stale, and SSH client picks up stale. Flush OS cache; browser may need separate flush via chrome://net-internals/#dns or similar.
Modern Ubuntu/Fedora/Arch use systemd-resolved by default — `resolvectl flush-caches`. RHEL/CentOS may use nscd — `nscd -i hosts`. Or `systemctl restart nscd`. Find which is running: `systemctl is-active systemd-resolved` and `systemctl is-active nscd`. Flush whichever is active.
Resolver upstream is stale or wrong. `dig +short hostname @1.1.1.1` (public resolver bypass) — if returns correct IP, your resolver is broken. Either switch resolvers (`/etc/resolv.conf` to `1.1.1.1`), or wait for upstream TTL to expire. Hosts file overrides are another common culprit.
Yes for fleet management. Ansible/Puppet snippets handle per-OS. For office environments, push via GPO (Windows) or MDM (macOS). For one-off fixes, manual flush per machine is fast. Set short TTL on DNS records in advance of any planned change to minimize cache lifetime.
Related articles
Fixing EAI_NONAME Error in FTP (DNS Resolution Failure)
Fix "ssh_init: host does not exist" in FileZilla on Systemd-Based Distros
Fix "ssh_init: host not found" Error in SSH