1,105,578 Community Members

Can't ping localhost

Member Avatar
aryan200x
Newbie Poster
9 posts since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a Linux(Centos 6.3) dedicated server. When i log into it through SSH(PuTTy) and issue the command 'root@p2953333#ping localhost' it gives the error 'ping: unknown host localhost' as i can ping any other ips including 127.0.0.1.
i have googled alot and find some solutions like checking settings in /etc/hosts and /etc/nsswitch.conf which are correct in my server.
Any help appreciated.

Thanks,

Member Avatar
CimmerianX
Practically a Master Poster
661 posts since Jul 2010
Reputation Points: 53 [?]
Q&As Helped to Solve: 83 [?]
Skill Endorsements: 13 [?]
 
0
 

cat /etc/hosts

You should see the lines similiar to:

    127.0.0.1      localhost
    127.0.0.1      servername.domain.local

Do you have this?

Member Avatar
aryan200x
Newbie Poster
9 posts since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks for help CimmerianX.

My /etc/hosts info is as below:

127.0.0.1 localhost.localdomain localhost
::1 localhost localhost6 localhost6.localdomain6
66.135.38.137 p2953393.pubip.serverbeach.com p2953393

and my /etc/resolv.conf info is as below:

domain pubip.serverbeach.com
options rotate
nameserver 216.187.125.131
nameserver 216.187.125.130

Please help me!

Member Avatar
CimmerianX
Practically a Master Poster
661 posts since Jul 2010
Reputation Points: 53 [?]
Q&As Helped to Solve: 83 [?]
Skill Endorsements: 13 [?]
 
0
 

Seems like your system is not checking the hosts file and thus can't resolve localhost to 127.0.0.1

Look at /etc/nsswitch.conf. This file should have certain permissions 644. If not, then use:

chmod 644 /etc/nsswitch.conf

Cat nsswitch.conf and make sure have the following:

hosts: files dns
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: