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

new-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,

192.168.0.103   new-hostname

Where. 192.168.0.103, 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 ]

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

$ ping new-hostname

PING new-hostname (192.168.0.103) 56(84) bytes of data.
64 bytes from new-hostname (192.168.0.103): icmp_seq=1 ttl=64 time=1.93 ms
64 bytes from new-hostname (192.168.0.103): icmp_seq=2 ttl=64 time=1.28 ms
64 bytes from new-hostname (192.168.0.103): icmp_seq=3 ttl=64 time=1.30 ms
^C
— 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.

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded
Tags:

Leave a Reply