How to resolve : getaddrinfo: new-hostname No address associated with hostname

Recently, we got the error “getaddrinfo: new-hostname No address associated with hostname” while working with some commands,
This error means, we are missing somewhere an assignment of IP and its related hostname.
You can use command,

$ hostname

To get, the hostname of your machine.

Now, to assign an IP with this hostname is,

sudo vim /etc/hosts

Add, a line like below, new-hostname

Where., is the IP you want to assign with hostname “new-hostname” [ Note: you can assign any IP as per your requirement in case you are trying to set for remote hostname ]

READ  How to fix Chrome error : "Something went wrong when opening your profile. Some features may be unavailable." on Linux

Save, and close the file, and now try to see if its working by using ping with hostname,

$ ping new-hostname

PING new-hostname ( 56(84) bytes of data.
64 bytes from new-hostname ( icmp_seq=1 ttl=64 time=1.93 ms
64 bytes from new-hostname ( icmp_seq=2 ttl=64 time=1.28 ms
64 bytes from new-hostname ( icmp_seq=3 ttl=64 time=1.30 ms
— new-hostname ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.282/1.509/1.939/0.305 ms

So, it seems now working.

Leave a Reply

Your email address will not be published. Required fields are marked *