Friday, August 10, 2012

"localhost" is not known on CentOS

localhost is not known
My linux system could not recognize its own localhost.
Here is several ways to check "localhost" work or not:
1. Enter following command in terminal, and localhost is the system's hostname:
# ping localhost
It will show you something looks like this:
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.086 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.121 ms
if it does not show you the above thing, it does not work, or you can check ping directly with your local ip address:
#ping 127.0.0.1   
2. Check localhost using ssh
#ssh localhost
It will show you something looks like this:
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is a3:0a:4f:d4:f1:73:6f:25:eb:92:70:9d:93:b8:45:4f.
Are you sure you want to continue connecting (yes/no)?
If not so, it means your hostname does not work properly.

HOWTO solve it?
1. Modify /etc/hosts
It looks like the following:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost mycentos
I added localhost and mycentos as my host name.
2.Try to flush DNS cache :
#/etc/init.d/nscd restart
It works for my system.












No comments:

Post a Comment