{"id":5163,"date":"2020-06-05T19:31:26","date_gmt":"2020-06-05T23:31:26","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=5163"},"modified":"2020-06-05T19:31:27","modified_gmt":"2020-06-05T23:31:27","slug":"sudo-unable-to-resolve-host-explained","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/","title":{"rendered":"Sudo: unable to resolve host explained"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"628\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg\" alt=\"Unable to resolve host explained.\" class=\"wp-image-5164\" srcset=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg 1200w, https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host-573x300.jpg 573w, https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host-768x402.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>Sometimes you encounter an error \u201csudo unable to resolve host\u201d. Usually, this error occurs after changing the hostname of <a href=\"https:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\" rel=\"noreferrer noopener\">your system<\/a>. The hostname is the name of your device that the network identifies with. The hostname is stored locally in the file &#8220;\/etc\/hostname&#8221;. It is mapped to the network for communication. This is not a big problem and can be solve it easily.<\/p>\n\n\n\n<p>In this tutorial, we will show you how to resolve \u201csudo unable to resolve host\u201d error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Identify the Error<\/h2>\n\n\n\n<p>Before starting, we need to identify the actual error with a hostname.<\/p>\n\n\n\n<p>First, check the hostname of <a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\" rel=\"noreferrer noopener\">your system<\/a> by running the following command:<\/p>\n\n\n\n<p><code> hostname<\/code><\/p>\n\n\n\n<p>You should see the following output:<\/p>\n\n\n\n<p><code> newpc<\/code><\/p>\n\n\n\n<p>The above output indicates that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hostname\" target=\"_blank\" rel=\"noreferrer noopener\">hostname <\/a>is already setup with your system.<\/p>\n\n\n\n<p>Next, run the following command to reproduce the error:<\/p>\n\n\n\n<p><code> sudo<\/code><\/p>\n\n\n\n<p>You should see the following screen:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"818\" height=\"210\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo.png\" alt=\"Sudo: unable to resolve host explained\" class=\"wp-image-5165\" srcset=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo.png 818w, https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-768x197.png 768w\" sizes=\"auto, (max-width: 818px) 100vw, 818px\" \/><\/figure>\n\n\n\n<p>As you can see, the message &#8220;sudo: unable to resolve host newpc&#8221; indicates that the hostname command cannot determine the IP address of host &#8220;newpc&#8221;<\/p>\n\n\n\n<p>In simple terms, the hostname command cannot resolve the hostname of your system. Since this a local computer and there is no such record in the DNS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Fix the Error<\/h2>\n\n\n\n<p>In order to fix the error, we will need to add the DNS record locally in your system. The local DNS record is stored in the \/etc\/hosts file.<\/p>\n\n\n\n<p>First, login to root user with the following command:<\/p>\n\n\n\n<p><code> su - root<\/code><\/p>\n\n\n\n<p>Next, see the content of the \/etc\/hosts file using the following command:<\/p>\n\n\n\n<p><code> cat \/etc\/hosts<\/code><\/p>\n\n\n\n<p>You should see the following screen:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"818\" height=\"193\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/print-hosts-file.png\" alt=\"Print \/etc\/hosts file content using cat command.\" class=\"wp-image-5166\" srcset=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/print-hosts-file.png 818w, https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/print-hosts-file-768x181.png 768w\" sizes=\"auto, (max-width: 818px) 100vw, 818px\" \/><\/figure>\n\n\n\n<p>As you can see, there is no such record of your hostname (newpc). Since the hostname is missing and your system is not able to figure out the hostname and thus it throws the error \u2018sudo: unable to resolve host\u2019.<\/p>\n\n\n\n<p>To fix this error, edit the \/etc\/hosts file and set the hostname (newpc) with a <a href=\"https:\/\/www.pcmag.com\/encyclopedia\/term\/loopback-address\" target=\"_blank\" rel=\"noreferrer noopener\">loopback <\/a>address (127.0.0.1).<\/p>\n\n\n\n<p><code> nano \/etc\/hosts<\/code><\/p>\n\n\n\n<p>Add the line &#8220;127.0.0.1 newpc&#8221; as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"232\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/edit-hosts-file.png\" alt=\"Edit \/etc\/hosts file content using nano test file editor.\" class=\"wp-image-5167\"\/><\/figure>\n\n\n\n<p>Save and close the file when you are finished. Then, test whether the error is resolved or not with the following command:<\/p>\n\n\n\n<p><code> sudo<\/code><\/p>\n\n\n\n<p>You should see the following screen:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1187\" height=\"155\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo2.png\" alt=\"Sudo command without Sudo: unable to resolve host error.\" class=\"wp-image-5168\" srcset=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo2.png 1187w, https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo2-768x100.png 768w\" sizes=\"auto, (max-width: 1187px) 100vw, 1187px\" \/><\/figure>\n\n\n\n<p>As you can see the error &#8220;sudo: unable to resolve host&#8221; disappeared.<\/p>\n\n\n\n<p><strong>Note<\/strong> : If the old hostname is present in the \/etc\/hosts file then just replace them with the new hostname.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In the above guide, we learned how to resolve &#8220;sudo: unable to resolve host&#8221; error in Linux. I hope you have now enough understanding of how hostname and \/etc\/hosts file works.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":5164,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[186,185],"class_list":["post-5163","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-use-case","tag-host","tag-unable-to-resolve"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sudo: unable to resolve host explained - Globo.Tech<\/title>\n<meta name=\"description\" content=\"Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sudo: unable to resolve host explained - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-05T23:31:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-05T23:31:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/\",\"name\":\"Sudo: unable to resolve host explained - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg\",\"datePublished\":\"2020-06-05T23:31:26+00:00\",\"dateModified\":\"2020-06-05T23:31:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#primaryimage\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg\",\"contentUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg\",\"width\":1200,\"height\":628,\"caption\":\"Sudo: unable to resolve host explained.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sudo: unable to resolve host explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sudo: unable to resolve host explained - Globo.Tech","description":"Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/","og_locale":"en_US","og_type":"article","og_title":"Sudo: unable to resolve host explained - Globo.Tech","og_description":"Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.","og_url":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/","og_site_name":"Globo.Tech","article_published_time":"2020-06-05T23:31:26+00:00","article_modified_time":"2020-06-05T23:31:27+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg","type":"image\/jpeg"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/","url":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/","name":"Sudo: unable to resolve host explained - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#primaryimage"},"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg","datePublished":"2020-06-05T23:31:26+00:00","dateModified":"2020-06-05T23:31:27+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"Sudo: unable to resolve host explained error can be seen in case your system is unable to resolve the local hostname. In this article, learn how to fix it.","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#primaryimage","url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg","contentUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2020\/06\/sudo-unable-to-resolve-host.jpg","width":1200,"height":628,"caption":"Sudo: unable to resolve host explained."},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/sudo-unable-to-resolve-host-explained\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"Sudo: unable to resolve host explained"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/5163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=5163"}],"version-history":[{"count":2,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/5163\/revisions"}],"predecessor-version":[{"id":5170,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/5163\/revisions\/5170"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media\/5164"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=5163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=5163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=5163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}