Here’s a fast repair to do away with the “unable to resolve host: Name or service not recognized” error on Linux.
After altering the hostname on your Linux system, you might encounter the error “unable to resolve host”. Here’s what meaning, and what you are able to do to repair it.
What Is a Hostname, and How Do You Change It?
When you arrange your Linux system—whether or not it is a VPS or a bodily machine in your house—you might be requested to present a hostname. This is a label your laptop makes use of to determine itself to different machines on the community, to the consumer, and to itself.
Hostnames ought to be descriptive in order that it is simple to determine machines—even whenever you’re not sitting instantly in entrance of them. “Kitchen PC”, or “David’s tiny laptop computer” are nice names. “racknerd-b7516a” is a horrible title and makes it troublesome to work out precisely which machine you are linked to.
Open a terminal by both urgent Ctrl + Alt + T, or by choosing it out of your menu system, then enter:
sudo hostnamectl set-hostname your-new-hostname
Log out after which log again in, and you will note that the hostname has modified.
What Does “unable to resolve host: Name or service not recognized” Mean?
After altering your system’s hostname, the subsequent time you strive to run a command as sudo, you may obtain a hostname error. In our case, the error was “unable to resolve host MUOVPS: Name or service not recognized”.
This error doesn’t forestall you from finishing up any duties, however it may be annoying.
cat /and so on/hostname
The aforementioned command will present the hostname you simply set, however your new hostname isn’t current as an output of:
cat /and so on/hosts
To repair this error, use nano to edit the file:
sudo nano /and so on/hosts
On a brand new line, add the hostname of your machine—the hostname of our VPS is MUOVPS as proven beneath—then save and exit nano with Ctrl + O then Ctrl + X.
You Have Fixed the “unable to resolve host” Error!
Hostname errors are usually not the most severe and are unlikely to considerably disrupt your workflow or your day. But they’re annoying and present that you have not configured your system correctly. For this purpose, it is price setting the hostname correctly.
Fixing this problem requires you to edit the /and so on/hosts file. Since it’s a vital system file, figuring out how to edit it correctly is essential to forestall any errors.