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 ]

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.

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question