How do I edit my hosts file on Mac?

How do I edit my hosts file on Mac?

How to Edit Mac Hosts File

  1. Step 1: Open the Mac Terminal. Open the Finder, and go to Applications > Utilities > Terminal. Type the following in the terminal window: sudo nano /private/etc/hosts.
  2. Step 2: Edit Mac Hosts File. The IP address is first, and the server name comes second. Comments are indicated with a ‘#’ sign.

How do you manually edit your hosts file?

Windows

  1. Press the Windows key.
  2. Type Notepad in the search field.
  3. In the search results, right-click Notepad and select Run as administrator.
  4. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts.
  5. Make the necessary changes to the file.
  6. Select File > Save to save your changes.

How do I change my localhost domain on a Mac?

Redirecting the Web Site to Your Computer

  1. Locate your hosts file.
  2. Open the file with a plain text editor (like Notepad++).
  3. Add lines containing the domain name(s) and IP address to redirect to.
  4. Save the changes.
  5. Restart your browser (if it was open when you made the change to your hosts file).

Can not edit etc hosts?

So if you only change the ”hosts” file permissions to ”read and write” you still won’t be able to edit it in TextEdit. The ”hosts” file is locked due to the ”/private/etc” folder. The trick is that you need to change both the permissions of ”/private/etc” folder then ”/private/etc/hosts” file.

How do I add to host file on Mac?

Modify Hosts File in macOS

  1. In your terminal window, open the hosts file using your favorite text editor: sudo nano /etc/hosts. When prompted, enter your administrative password.
  2. Scroll down to the end of the file and add your new entries:
  3. Save the changes and flush the DNS cache: dscacheutil -flushcache.