How to fix error can’t ping any hostname on Linux


How to fix error can’t ping any hostname on Linux?

[root@tutorialspots ~]# ping google.com
ping: google.com: Name or service not known

But you can ping IP. So strange! How to fix this error?
Simple, you only need flush DNS cache.
You can read this artice: How to flush DNS cache on CentOS

Example:

service named restart

Now you can ping hostname

[root@tutorialspots ~]# ping google.com
PING google.com (172.217.12.78) 56(84) bytes of data.
64 bytes from dfw28s05-in-f14.1e100.net (172.217.12.78): icmp_seq=1 ttl=57 time=10.8 ms
64 bytes from dfw28s05-in-f14.1e100.net (172.217.12.78): icmp_seq=2 ttl=57 time=10.6 ms
64 bytes from dfw28s05-in-f14.1e100.net (172.217.12.78): icmp_seq=3 ttl=57 time=10.7 ms

cant ping hostname on linux

If you get this error:

[root@tutorialspots ~]# service named restart
Redirecting to /bin/systemctl restart named.service
Authorization not available. Check if polkit service is running or see debug message for more information.

You must reboot your server.

Leave a Reply