I host an ubuntu server at a data center and worked well for years till last night the server can not ping itself by host name. No config has been changed. Here are what it can/can not do now.

  • From outside, I can ping the server both by its static IP, and by its hostname.
  • From server, I can ping any website (google, yahoo, ...).
  • From server, I can ping localhost, and can ping the IP of server itself.
  • From server, I can not ping sever itself by its hostname.

Here is /etc/network/interfaces:

source /etc/network/interfaces.d/* 

auto lo
iface lo inet loopback

auto enp5s0

iface enp5s0 inet static
address xxx.xxx.xxx.134
broadcast xxx.xxx.xxx.255
gateway xxx.xxx.xxx.129

and /etc/resolv.conf:


and /etc/resolvconf/resolv.conf.d/head:


and the output of route -n is:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         xxx.xxx.xxx.129         UG    0      0        0 enp5s0
xxx.xxx.xxx.128 U     0      0        0 enp5s0     U     0      0        0 docker0

These configs worked for years. Wondering what happened? Thanks.

  • Just put your servers IP + the hostname(s) into your /etc/hosts file. x.x.x.x somehostname.com hostname – Michael D. Apr 10 '19 at 20:48
  • When you run the ping command, what IP address does it say it’s using? – G-Man Says 'Reinstate Monica' Apr 10 '19 at 20:56
  • @G-Man ping stalls. – Sia Apr 11 '19 at 3:05
  • @Michael D, that worked, thank you! Wondering how come I did not need it before. – Sia Apr 11 '19 at 3:05

Check /etc/hosts. Probably there's a line with the name of the server and an incorrect IP

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.