Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known [closed]

People also ask

How do you fix SSH could not resolve hostname?

Editing the /etc/hosts file If you are trying to connect to a remote host using ssh for the first time and getting a hostname error not resolved error in return, try editing the ssh hosts file and entering the username and hostname in the file.

What does could not resolve host mean?

What is the meaning of error: 'Unable to resolve host name'? This error means that the hostname you are trying to connect to cannot be resolved to an IP address. (Hostnames are resolved to IP addresses by a DNS (Domain NameServer)). Please check what you have entered in the Address field.


If you're on Mac, restarting the DNS responder fixed the issue for me.

sudo killall -HUP mDNSResponder

I had the same issue connecting to a remote machine. but I managed to login as below:

ssh -p 22 myName@hostname

or:

ssh -l myName -p 22 hostname

Recently I came across the same issue. I was able to ssh to my pi on my network, but not from outside my home network.

I had already:

  • installed and tested ssh on my home network.
  • Set a static IP for my pi.
  • Set up a Dynamic DNS service and installed the software on my pi. I referenced these instructions for setting up the static ip, and there are many more instructional resources out there.

Also, I set up port forward on my router for hosting a web site and I had even port forward port 22 to my pi's static IP for ssh, but I left the field blank where you specify the application you are performing the port forwarding for on the router. Anyway, I added 'ssh' into this field and, VOILA! A working ssh connection from anywhere to my pi.

I'll write out my router's port forwarding settings.

(ApplicationTextField)_ssh     (external port)_22     (Internal Port)_22     (Protocal)_Both     (To IP Address)_192.168.1.###     (Enabled)_checkBox

Port forwarding settings can be different for different routers though, so look up directions for your router.

Now, when I am outside of my home network I connect to my pi by typing:

ssh pi@[hostname]

Then I am able to input my password and connect.


In my case I was trying ssh like this

ssh [email protected]:22 

when the correct format is:

ssh [email protected] -p 22