How do I edit my hosts file on Windows or Mac? Print

  • 0

You can check the websites by adding host entry for all the sites on your local machine. To use the hosts file to bypass DNS for your domain:

    Open the hosts file in a text editor such as notepad on Windows computer. The location of the hosts file depends on your computer's operating system:

-- On Microsoft Windows computers, the hosts file is located at C:\Windows\System32\drivers\etc\hosts
-- On Apple Macintosh computers, the hosts file is located at /private/etc/hosts
-- On Linux computers, the hosts file is located at /etc/hosts


In Windows when you open the hosts file (C:\Windows\System32\drivers\etc\hosts), you should see an entry that resembles the following line:

127.0.0.1 localhost

    To create a new mapping for your domain, add the following line to the file:

server-IP  your-domainname

For example

1.1.1.1 test.com www.test.com
2.2.2.2 test.com.au www.test.com.au

    Save the hosts file and exit the text editor.

    To test the configuration, restart your web browser and go to test.com or www.test.com

To edit the hosts file in MAC OS

To open Hosts file on Mac, which is hidden, you need to use Terminal:

1 Launch Terminal

2. Type sudo nano /etc/hosts and press Return

3. Enter your admin password

4. Use the Return key to create some space below the existing records
5. Type in the TCP/IP address

6. Press the Tab key

7. Enter the domain name

For example

1.1.1.1 test.com www.test.com
2.2.2.2 test.com.au www.test.com.au

8. Save the file by pressing Ctrl + O

9. Exit with Ctrl + X

10. In Terminal, type sudo killall -HUP mDNSResponder followed by Return to clear your Mac’s DNS cache and prevent any clashes between DNS and the Hosts file.

Alternativley you can also check using the below method:

    Access website: https://hosts.cx/
    In the Server address enter the IP for example 1.1.1.1
    In the Website name box enter the website name, for example test.com
    Tick the box 'I'm not robot'
    Click on 'Get my Testing URL'

You will get the testing URL which you can access in browser.


Was this answer helpful?

« Back