{"id":7234,"date":"2023-02-05T17:53:41","date_gmt":"2023-02-05T17:53:41","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=7234"},"modified":"2023-02-05T17:53:41","modified_gmt":"2023-02-05T17:53:41","slug":"change-a-hosts-file-on-a-mac","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2023\/02\/05\/change-a-hosts-file-on-a-mac\/","title":{"rendered":"Change a hosts file on a Mac"},"content":{"rendered":"\n<p>We often get asked this question a lot as in many cases. With the information in this article, we will outline how to map a domain name to the local hosts file, thus overriding temporarily the DNS record for a domain.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><\/p>\n\n\n\n<p>Here are the steps to change the hosts file on a Mac:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Terminal app.<\/li>\n\n\n\n<li>Use the following command to open the hosts file in a text editor:<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsudo nano \/private\/etc\/hosts\n<\/pre><\/div>\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Enter your password when prompted.<\/li>\n\n\n\n<li>Make the desired changes to the hosts file. For example, to add an IP to a website, add the following line to the file:<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n192.168.0.1 example.com\n<\/pre><\/div>\n\n\n<p>Note: Replace &#8220;192.168.0.1&#8221; with your new IP address and &#8220;example.com&#8221; with the actual domain name of the website you want to add.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Save the changes to the file by pressing <code>Ctrl + X<\/code>, then <code>Y<\/code>, and finally <code>Enter<\/code>.<\/li>\n\n\n\n<li>Close the Terminal app.<\/li>\n\n\n\n<li>Flush the DNS cache to ensure that the changes take effect. You can do this by using the following command in the Terminal app:<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndscacheutil -flushcache;sudo killall -HUP mDNSResponder\n\n<\/pre><\/div>\n\n\n<p>Your Mac&#8217;s hosts file is now updated, and the changes should take effect immediately.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We often get asked this question a lot as in many cases. With the information in this article, we will outline how to map a domain name to the local hosts file, thus overriding temporarily the DNS record for a domain.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,60],"tags":[],"class_list":["post-7234","post","type-post","status-publish","format-standard","hentry","category-apple","category-mac"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/7234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=7234"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/7234\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=7234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=7234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=7234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}