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

Fix "ssh_init: host not found" Error in SSH

4 min read
15.03.2026

1. Use IP Address Instead of Hostname

To bypass DNS resolution issues entirely, try connecting with your server's IP address instead of its hostname.

SSH host not found
"host not found" variant — same diagnostic order as "host does not exist".

For the FileZilla-specific variants and DNS-cache angle, see FileZilla — Use IP Instead of Hostname, systemd-resolved Linux variant, and Flush DNS Cache.

Find Your Server's IP Address

Windows Command Prompt:

nslookup yourserver.com

Linux/macOS Terminal:

dig yourserver.com +short

or

host yourserver.com

Example Output:

192.168.1.10

Use the IP Address in SSH Instead

Instead of connecting with the hostname:

ssh user@yourserver.com

Try connecting with the IP address:

ssh user@192.168.1.10

Diagnostic Result:

  • If the IP connection works, the issue is definitely with DNS resolution.
  • If SSH still fails even with the IP, the problem may be network-related, firewall-related, or the SSH service might not be running on the server. Proceed to the next steps.

2. Verify DNS Resolution

If the hostname is not resolving, check your system's DNS settings directly.

Check DNS Resolution

For Windows:

nslookup yourserver.com

For Linux/macOS:

systemd-resolve yourserver.com

or

host yourserver.com

Expected Results:

  • If an IP address is returned (e.g., 192.168.1.10), DNS is working correctly from your system's perspective.
  • If you see "host not found", "NXDOMAIN", or no IP address appears, DNS is failing and you should move to the next step.

3. Manually Add Hostname to /etc/hosts

If DNS is not resolving the hostname, you can manually map it to its IP address on your local system. This is a reliable workaround that bypasses external DNS entirely.

Edit the Hosts File

For Linux/macOS:

sudo nano /etc/hosts

Add this line at the end of the file (use your actual IP and hostname):

192.168.1.10 yourserver.com

Save (Ctrl+O) and exit (Ctrl+X).

For 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 or command prompt.

Now SSH should recognize the hostname by checking this local file first.

4. Flush DNS Cache

Clear old or corrupted DNS records from your system's cache to force it to retrieve fresh information.

Clear DNS Cache

For Windows:

ipconfig /flushdns

For macOS:

sudo killall -HUP mDNSResponder

For Linux (systemd-based distros like Ubuntu, Debian, CentOS 8+):

sudo systemd-resolve --flush-caches

After running the appropriate command for your OS, retry your SSH connection.

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

5. Restart Network Services

Restarting your network interface can refresh all connection settings, including DNS.

Restart Networking

Linux/macOS:

sudo systemctl restart networking

or

nmcli networking off && nmcli networking on

Windows:

ipconfig /release
ipconfig /renew

Now try connecting again with SSH.

6. Check Firewall & SSH Port

If DNS is working but SSH still fails, the connection might be blocked by a firewall.

Test If the SSH Port Is Open

Run one of these diagnostic commands:

nc -zv yourserver.com 22

or

telnet yourserver.com 22

Interpretation:

  • If it connects successfully, the SSH service is reachable on port 22.
  • If you see "Connection refused" or it times out, the SSH port is blocked, the service is not running, or the host is unreachable.

Allow SSH in Firewall (Server-Side Configuration)

Configure Server Firewall

For UFW (Ubuntu/Debian) - Run these on your server:

sudo ufw allow 22/tcp
sudo ufw reload

For Firewalld (CentOS/RHEL) - Run these on your server:

sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload

Now try SSH again from your client machine.

7. Check SSH Client Configuration

Your SSH client may have incorrect settings in its configuration file that are causing the hostname resolution to fail.

  1. Open your user-specific SSH configuration file:
    nano ~/.ssh/config
  2. Verify the host entry for your server is defined correctly. A standard entry looks like:
    Host myserver
        HostName yourserver.com
        User username
        Port 22
        IdentityFile ~/.ssh/id_rsa
  3. Save the file (Ctrl+O, then Enter, then Ctrl+X).
  4. Now test the connection using your configured alias:
    ssh myserver

Ensure the HostName directive contains the correct, resolvable address.

8. Summary of Fixes

Issue Fix
Hostname not resolving (ssh_init: host not found) Use server IP instead of hostname
DNS lookup fails Test with nslookup or dig, and manually add host to /etc/hosts
DNS is outdated Flush DNS with ipconfig /flushdns (Windows) or systemd-resolve --flush-caches (Linux)
Firewall blocking SSH Open port 22 with ufw allow 22/tcp or firewall-cmd --add-service=ssh --permanent
SSH config incorrect Check ~/.ssh/config and update HostName
Network issues Restart networking with systemctl restart networking

By systematically following these troubleshooting steps, SSH should work without the "ssh_init: host not found" error!

Frequently asked questions
Yes — PuTTY's "Server unexpectedly closed network connection" can result from various causes including DNS. Check PuTTY's category: "Connection" → host typed correctly? "Connection → Proxy" might be misconfigured. Add hostname to Windows hosts file as bypass. Same per-OS DNS flush applies; just the surface error wording differs.
macOS often takes split-DNS via VPN configuration. mDNSResponder may route .corp domains via VPN and public domains via host ISP. If your SSH target is on neither path, resolution fails. `scutil --dns` shows current resolver configuration. Often `sudo killall -HUP mDNSResponder` fixes after VPN restart.
Same network, same DNS, different result. Most likely: working machine has hostname in its hosts file (legacy entry). Check `/etc/hosts` on the working machine; if hostname is there, that's why. Either also add to the failing machine, or fix DNS so both machines resolve via DNS consistently.
Cisco AnyConnect has a history of DNS issues — pushes corporate resolver but doesn't always cleanly take it back when disconnecting. Symptoms: first SSH attempts after VPN connect/disconnect cycle fail. Fix: `sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder` (macOS), then retry. Long-term, complain to corporate IT about VPN client behavior.
Related articles
550-5.7.1 "Likely Unsolicited Mail" Error
Unable to Resolve Target System Name Error
Fix "ssh_init: host does not exist" Error in SSH